Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf/dwc_pcie: Fix PCI device reference leak in probe
@ 2026-08-14 13:39 Ruoyu Wang
  2026-08-14 13:51 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-08-14 13:39 UTC (permalink / raw)
  To: Shuai Xue, Jing Zhang, Will Deacon, Mark Rutland, Yunhui Cui
  Cc: linux-arm-kernel, linux-perf-users, linux-kernel, Ruoyu Wang

pci_get_domain_bus_and_slot() returns a referenced PCI device. When the
subsequent RAS DES capability lookup fails, dwc_pcie_pmu_probe() returns
-ENODEV without releasing that reference. Repeated failed probes can
therefore keep the PCI device allocated after removal.

Move the existing pci_dev_put() immediately after capability discovery
so the temporary lookup reference is released on both success and
failure paths.

This issue was found by a static analysis checker and confirmed by
manual source review.

Fixes: 7f35b429802a ("perf/dwc_pcie: fix duplicate pci_dev devices")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/perf/dwc_pcie_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/perf/dwc_pcie_pmu.c b/drivers/perf/dwc_pcie_pmu.c
index 5385401fa9cf6..baa736fd9a6ef 100644
--- a/drivers/perf/dwc_pcie_pmu.c
+++ b/drivers/perf/dwc_pcie_pmu.c
@@ -710,10 +710,10 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)
 	}
 
 	vsec = dwc_pcie_des_cap(pdev);
+	pci_dev_put(pdev);
 	if (!vsec)
 		return -ENODEV;
 
-	pci_dev_put(pdev);
 	name = devm_kasprintf(&plat_dev->dev, GFP_KERNEL, "dwc_rootport_%x", sbdf);
 	if (!name)
 		return -ENOMEM;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-14 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 13:39 [PATCH] perf/dwc_pcie: Fix PCI device reference leak in probe Ruoyu Wang
2026-08-14 13:51 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox