mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Suthikulpanit, Suravee" <suravee.suthikulpanit@amd.com>
To: "Kun(llfl)" <llfl@linux.alibaba.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Jerry Snitselaar <jsnitsel@redhat.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	Vasant Hegde <vasant.hegde@amd.com>
Subject: Re: [PATCH 1/1] iommu/amd: Fix sysfs leak in iommu init
Date: Tue, 7 May 2024 16:12:14 +0700	[thread overview]
Message-ID: <8cb9ad12-1426-43b6-830f-277d3b3b6a02@amd.com> (raw)
In-Reply-To: <4d516a6500ea0760e13cc19e2b14e663aa333518.1715048443.git.llfl@linux.alibaba.com>

Thanks for finding this sysfs leak.

On 5/7/2024 9:32 AM, Kun(llfl) wrote:
> During the iommu initialization, iommu_init_pci() adds sysfs nodes.
> However, these nodes aren't remove in free_iommu_resources() subsequently.
> 
> Fixes: ad8694bac410 ("iommu/amd: Move AMD IOMMU driver into subdirectory")

Actually, this commit only move the code into new directory structure. 
The original commit was:

commit 39ab9555c24110671f8dc671311a26e5c985b592
Author: Joerg Roedel <jroedel@suse.de>
Date:   Wed Feb 1 16:56:46 2017 +0100

     iommu: Add sysfs bindings for struct iommu_device

> Signed-off-by: Kun(llfl) <llfl@linux.alibaba.com>
> ---
>   drivers/iommu/amd/init.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index ac6754a85f35..624ea2549f64 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -1678,8 +1678,15 @@ static void __init free_pci_segments(void)
>   	}
>   }
>   
> +static void __init free_sysfs(struct amd_iommu *iommu)
> +{
> +	if (iommu->iommu.dev)
> +		iommu_device_sysfs_remove(&iommu->iommu);
> +}
> +
>   static void __init free_iommu_one(struct amd_iommu *iommu)
>   {
> +	free_sysfs(iommu);

As part of the clean up, we also need to also call 
iommu_device_unregister() before iommu_device_sysfs_remove().

Thanks,
Suravee

>   	free_cwwb_sem(iommu);
>   	free_command_buffer(iommu);
>   	free_event_buffer(iommu);

      reply	other threads:[~2024-05-07  9:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07  2:32 Kun(llfl)
2024-05-07  9:12 ` Suthikulpanit, Suravee [this message]

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=8cb9ad12-1426-43b6-830f-277d3b3b6a02@amd.com \
    --to=suravee.suthikulpanit@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=jsnitsel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llfl@linux.alibaba.com \
    --cc=robin.murphy@arm.com \
    --cc=vasant.hegde@amd.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®