[PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()
From: Wentao Liang
Date: Thu Sep 17 2026 - 09:32:31 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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