[PATCH] iommu/amd: Fix root bridge reference leak in iommu_init_pci()

Wentao Liang posted 1 patch 1 week, 1 day ago
drivers/iommu/amd/init.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] iommu/amd: Fix root bridge reference leak in iommu_init_pci()
Posted by Wentao Liang 1 week, 1 day ago
iommu_init_pci() caches a reference to the root bridge in
iommu->root_pdev so that iommu_apply_resume_quirks() can reprogram the
IOMMU on resume without calling pci_get_bus_and_slot(), but nothing
ever drops that reference again, so it is leaked when the IOMMU is
freed.

Release iommu->root_pdev in free_iommu_one() as well.

Fixes: c1bf94ec1e12 ("iommu/amd: Cache pdev pointer to root-bridge")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/iommu/amd/init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 4b155970151d..c92f7e64453a 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -1811,6 +1811,7 @@ static void __init free_iommu_one(struct amd_iommu *iommu)
 	iommu_unmap_mmio_space(iommu);
 	amd_iommu_iopf_uninit(iommu);
 	pci_dev_put(iommu->dev);
+	pci_dev_put(iommu->root_pdev);
 }
 
 static void __init free_iommu_all(void)
-- 
2.34.1