iommu/amd: Fix sysfs leak in iommu init
Subsystems (2)
PATCH 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.
--- drivers/iommu/amd/init.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iommu/amd/init.c +7 -0
@@ -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);free_cwwb_sem (iommu);free_command_buffer (iommu);free_event_buffer (iommu);
Signature · 1 line
2.43.0
Suthikulpanit, Suravee
reviewerThanks for finding this sysfs leak.
Quoted 4 lines · Kun(llfl)
During the iommu initialization,
iommu_init_pci()adds sysfs nodes. However, these nodes aren't remove infree_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 <[email protected]> Date: Wed Feb 1 16:56:46 2017 +0100
iommu: Add sysfs bindings for struct iommu_device
Quoted 12 lines
Signed-off-by Kun(llfl) <[email protected]>--- drivers/iommu/amd/init.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/iommu/amd/init.c +0
-0@@ -1678,8 +1678,15 @@ static void __init free_pci_segments(void) } }
drivers/iommu/amd/init.c static void __init free_pci_segments(void) · line 1689
Quoted 10 lines
drivers/iommu/amd/init.c +7
-0+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
Quoted 3 lines
drivers/iommu/amd/init.c +0
-0free_cwwb_sem (iommu);free_command_buffer (iommu);free_event_buffer (iommu);