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

Wentao Liang vulab at iscas.ac.cn
Thu Sep 17 06:22:35 PDT 2026


xgene_pcie_probe() takes a reference to the port's device node with
of_node_get(), but returns directly from the error paths of
xgene_pcie_map_reg(), xgene_pcie_init_port(), xgene_pcie_setup() and
pci_host_probe(), leaking that reference on each of them.

Add an err_put_node label that drops the reference before returning.

Fixes: 5f6b6ccdbe1c ("PCI: xgene: Add APM X-Gene PCIe driver")
Cc: stable at vger.kernel.org
Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
 drivers/pci/controller/pci-xgene.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c
index b95afa35201d..6b00ec60ede6 100644
--- a/drivers/pci/controller/pci-xgene.c
+++ b/drivers/pci/controller/pci-xgene.c
@@ -633,20 +633,28 @@ static int xgene_pcie_probe(struct platform_device *pdev)
 
 	ret = xgene_pcie_map_reg(port, pdev);
 	if (ret)
-		return ret;
+		goto err_put_node;
 
 	ret = xgene_pcie_init_port(port);
 	if (ret)
-		return ret;
+		goto err_put_node;
 
 	ret = xgene_pcie_setup(port);
 	if (ret)
-		return ret;
+		goto err_put_node;
 
 	bridge->sysdata = port;
 	bridge->ops = &xgene_pcie_ops;
 
-	return pci_host_probe(bridge);
+	ret = pci_host_probe(bridge);
+	if (ret)
+		goto err_put_node;
+
+	return 0;
+
+err_put_node:
+	of_node_put(port->node);
+	return ret;
 }
 
 static const struct of_device_id xgene_pcie_match_table[] = {
-- 
2.34.1




More information about the linux-arm-kernel mailing list