From: Jerry Snitselaar <jsnitsel@redhat.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>
Subject: Re: [PATCH] iommu/vt-d: Clean up si_domain in the init_dmars() error path
Date: Mon, 10 Oct 2022 07:33:09 -0700 [thread overview]
Message-ID: <20221010143309.ed5pnkw2stjb26sc@cantor> (raw)
In-Reply-To: <35cf84fb-7672-671a-4354-0fb66bd2f8e7@linux.intel.com>
On Mon, Oct 10, 2022 at 07:32:43PM +0800, Baolu Lu wrote:
> On 2022/10/10 14:56, Jerry Snitselaar wrote:
> > A splat from kmem_cache_destroy() was seen with a kernel prior to
> > commit ee2653bbe89d ("iommu/vt-d: Remove domain and devinfo mempool")
> > when there was a failure in init_dmars(), because the iommu_domain
> > cache still had objects. While the mempool code is now gone, there
> > still is a leak of the si_domain memory if init_dmars() fails. So
> > clean up si_domain in the init_dmars() error path.
> >
> > Cc: Lu Baolu <baolu.lu@linux.intel.com>
> > Cc: Joerg Roedel <joro@8bytes.org>
> > Cc: Will Deacon <will@kernel.org>
> > Cc: Robin Murphy <robin.murphy@arm.com>
> > Fixes: 86080ccc223a ("iommu/vt-d: Allocate si_domain in init_dmars()")
> > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > ---
> > drivers/iommu/intel/iommu.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index 31bc50e538a3..8f1f80a4d0c5 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -3042,6 +3042,8 @@ static int __init init_dmars(void)
> > disable_dmar_iommu(iommu);
> > free_dmar_iommu(iommu);
> > }
> > + if (si_domain)
> > + domain_exit(si_domain);
>
> Thank you for the patch.
>
> Above requires si_domain to be NULL or a valid pointer. So do you also
> need to add the following change?
>
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -2410,6 +2410,7 @@ static int __init si_domain_init(int hw)
>
> if (md_domain_init(si_domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) {
> domain_exit(si_domain);
> + si_domain = NULL;
> return -EFAULT;
> }
>
> Best regards,
> baolu
Hi Baolu,
Yes. I think should add it after the domain_exit() call I added as well.
Regards,
Jerry
next prev parent reply other threads:[~2022-10-10 14:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 6:56 Jerry Snitselaar
2022-10-10 11:32 ` Baolu Lu
2022-10-10 14:33 ` Jerry Snitselaar [this message]
2022-10-10 14:48 ` [PATCH v2] " Jerry Snitselaar
2022-10-19 0:54 ` Baolu Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221010143309.ed5pnkw2stjb26sc@cantor \
--to=jsnitsel@redhat.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®