]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iommu/amd: Fix sysfs leak in iommu init
authorKun(llfl) <llfl@linux.alibaba.com>
Thu, 9 May 2024 00:42:20 +0000 (08:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jul 2024 07:08:16 +0000 (09:08 +0200)
[ Upstream commit a295ec52c8624883885396fde7b4df1a179627c3 ]

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>
Link: https://lore.kernel.org/r/c8e0d11c6ab1ee48299c288009cf9c5dae07b42d.1715215003.git.llfl@linux.alibaba.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/amd_iommu_init.c

index 15e25f712f393650b60e87eaa448e60f0ba588e1..0abb714fdbf109cc8cca5c42cf3a6d1b89662114 100644 (file)
@@ -1410,8 +1410,17 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
        return 0;
 }
 
+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_command_buffer(iommu);
        free_event_buffer(iommu);
        free_ppr_log(iommu);