Skip to contentSkip to conversation

iommu/amd/iommu_v2: fix pci device refcount leak in ppr_notifier()

PATCH Applied Yang Yingliang 2 participants 2 messages Nov 18, 2022 – Nov 19, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd/iommu_v2: fix pci device refcount leak in ppr_notifier()

As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put(). So call it before returning from ppr_notifier() to avoid refcount leak.

Fixes daae2d25a477 ("iommu/amd: Don't copy GCR3 table root pointer")
---
 drivers/iommu/amd/iommu_v2.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/amd/iommu_v2.c +1 -0
index 6a1f02c62dff..9f7fab49a5a9 100644
@@ -587,6 +587,7 @@ static int ppr_notifier(struct notifier_block *nb, unsigned long e, void *data)
 	put_device_state(dev_state);
 
 out:
+	pci_dev_put(pdev);
 	return ret;
 }
 
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 11 lines · Yang Yingliang

As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put(). So call it before returning from ppr_notifier() to avoid refcount leak.

Fixes daae2d25a477 ("iommu/amd: Don't copy GCR3 table root pointer")
---
 drivers/iommu/amd/iommu_v2.c | 1 +
 1 file changed, 1 insertion(+)

Applied, thanks.