* [PATCH] iommu/amd/iommu_v2: fix pci device refcount leak in ppr_notifier()
@ 2022-11-18 9:36 Yang Yingliang
2022-11-19 9:56 ` Joerg Roedel
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-11-18 9:36 UTC (permalink / raw)
To: joro, suravee.suthikulpanit; +Cc: iommu, yangyingliang
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")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/iommu/amd/iommu_v2.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iommu/amd/iommu_v2.c b/drivers/iommu/amd/iommu_v2.c
index 6a1f02c62dff..9f7fab49a5a9 100644
--- a/drivers/iommu/amd/iommu_v2.c
+++ b/drivers/iommu/amd/iommu_v2.c
@@ -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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] iommu/amd/iommu_v2: fix pci device refcount leak in ppr_notifier()
2022-11-18 9:36 [PATCH] iommu/amd/iommu_v2: fix pci device refcount leak in ppr_notifier() Yang Yingliang
@ 2022-11-19 9:56 ` Joerg Roedel
0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2022-11-19 9:56 UTC (permalink / raw)
To: Yang Yingliang; +Cc: suravee.suthikulpanit, iommu
On Fri, Nov 18, 2022 at 05:36:04PM +0800, Yang Yingliang wrote:
> 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")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/iommu/amd/iommu_v2.c | 1 +
> 1 file changed, 1 insertion(+)
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-19 9:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-18 9:36 [PATCH] iommu/amd/iommu_v2: fix pci device refcount leak in ppr_notifier() Yang Yingliang
2022-11-19 9:56 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox