iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] iommu/amd: Fix sysfs leak in iommu init
@ 2024-05-09  0:42 Kun(llfl)
  2024-05-13  6:45 ` Suthikulpanit, Suravee
  0 siblings, 1 reply; 2+ messages in thread
From: Kun(llfl) @ 2024-05-09  0:42 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Jerry Snitselaar
  Cc: Suravee Suthikulpanit, Robin Murphy, iommu, linux-kernel

During the iommu initialization, iommu_init_pci() adds sysfs nodes.
However, these nodes aren't remove in free_iommu_resources() subsequently.

Fixes: 39ab9555c241 ("iommu: Add sysfs bindings for struct iommu_device")
Signed-off-by: Kun(llfl) <llfl@linux.alibaba.com>
---
 drivers/iommu/amd/init.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index ac6754a85f35..82a54898194a 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -1678,8 +1678,17 @@ static void __init free_pci_segments(void)
 	}
 }
 
+static void __init free_sysfs(struct amd_iommu *iommu)
+{
+	if (iommu->iommu.dev) {
+		iommu_device_unregister(&iommu->iommu);
+		iommu_device_sysfs_remove(&iommu->iommu);
+	}
+}
+
 static void __init free_iommu_one(struct amd_iommu *iommu)
 {
+	free_sysfs(iommu);
 	free_cwwb_sem(iommu);
 	free_command_buffer(iommu);
 	free_event_buffer(iommu);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 1/1] iommu/amd: Fix sysfs leak in iommu init
  2024-05-09  0:42 [PATCH v2 1/1] iommu/amd: Fix sysfs leak in iommu init Kun(llfl)
@ 2024-05-13  6:45 ` Suthikulpanit, Suravee
  0 siblings, 0 replies; 2+ messages in thread
From: Suthikulpanit, Suravee @ 2024-05-13  6:45 UTC (permalink / raw)
  To: Kun(llfl), Joerg Roedel, Will Deacon, Jerry Snitselaar
  Cc: Robin Murphy, iommu, linux-kernel



On 5/9/2024 7:42 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: 39ab9555c241 ("iommu: Add sysfs bindings for struct iommu_device")
> Signed-off-by: Kun(llfl) <llfl@linux.alibaba.com>

Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-13  6:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-09  0:42 [PATCH v2 1/1] iommu/amd: Fix sysfs leak in iommu init Kun(llfl)
2024-05-13  6:45 ` Suthikulpanit, Suravee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).