[PATCH] perf/dwc_pcie: Fix PCI device reference leak in dwc_pcie_pmu_probe()

COLD26d

From: Wentao Liang <hidden>
Date: 2026-09-17 13:32:51
Also in: linux-perf-users, lkml, stable
Subsystem: arm pmu profiling and debugging, synopsys designware pcie pmu driver, the rest · Maintainers: Will Deacon, Mark Rutland, Shuai Xue, Jing Zhang, Linus Torvalds

dwc_pcie_pmu_probe() gets a reference to the PCI device with
pci_get_domain_bus_and_slot(), but returns -ENODEV directly when
dwc_pcie_des_cap() does not find the RAS DES capability, leaking the
reference.  The other early returns and the success path drop it.

Release the reference on that path as well.

Fixes: 7f35b429802a ("perf/dwc_pcie: fix duplicate pci_dev devices")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <redacted>
---
 drivers/perf/dwc_pcie_pmu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/perf/dwc_pcie_pmu.c b/drivers/perf/dwc_pcie_pmu.c
index 5385401fa9cf..edaf5d2e0daa 100644
--- a/drivers/perf/dwc_pcie_pmu.c
+++ b/drivers/perf/dwc_pcie_pmu.c
@@ -710,8 +710,10 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)
 	}
 
 	vsec = dwc_pcie_des_cap(pdev);
-	if (!vsec)
+	if (!vsec) {
+		pci_dev_put(pdev);
 		return -ENODEV;
+	}
 
 	pci_dev_put(pdev);
 	name = devm_kasprintf(&plat_dev->dev, GFP_KERNEL, "dwc_rootport_%x", sbdf);
-- 
2.34.1

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help