[PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()

Ruoyu Wang <[email protected]>
Newsgroups org.kernel.vger.linux-pci,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
xgene_pcie_probe() takes an extra reference to the platform device's OF
node and stores it in port->node. The driver never drops the reference,
so every probe attempt that reaches this point leaks it, including when
CSR mapping or a later initialization step fails.

The platform device already holds the node reference, and port->node is
only dereferenced synchronously by xgene_pcie_setup() before probe
returns. Store the borrowed pointer instead of taking another reference.

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

Fixes: 5f6b6ccdbe1c ("PCI: xgene: Add APM X-Gene PCIe driver")
Signed-off-by: Ruoyu Wang <[email protected]>
---
 drivers/pci/controller/pci-xgene.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c
index b95afa35201d0..cf9760f3a008e 100644
--- a/drivers/pci/controller/pci-xgene.c
+++ b/drivers/pci/controller/pci-xgene.c
@@ -627,7 +627,7 @@ static int xgene_pcie_probe(struct platform_device *pdev)
 
 	port = pci_host_bridge_priv(bridge);
 
-	port->node = of_node_get(dn);
+	port->node = dn;
 	port->dev = dev;
 	port->version = XGENE_PCIE_IP_VER_1;
 
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.