2024-05-09 00:42:51

by Kun(llfl)

[permalink] [raw]
Subject: [PATCH v2 1/1] iommu/amd: Fix sysfs leak in iommu init

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) <[email protected]>
---
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



2024-05-13 06:45:46

by Suthikulpanit, Suravee

[permalink] [raw]
Subject: Re: [PATCH v2 1/1] iommu/amd: Fix sysfs leak in iommu init



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) <[email protected]>

Reviewed-by: Suravee Suthikulpanit <[email protected]>

2024-06-04 11:51:01

by Joerg Roedel

[permalink] [raw]
Subject: Re: [PATCH v2 1/1] iommu/amd: Fix sysfs leak in iommu init

On Thu, May 09, 2024 at 08:42:20AM +0800, Kun(llfl) wrote:
> drivers/iommu/amd/init.c | 9 +++++++++
> 1 file changed, 9 insertions(+)

Applied, thanks.