* [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()
@ 2026-09-17 13:22 Wentao Liang
2026-09-18 11:50 ` kernel test robot
2026-09-18 12:37 ` kernel test robot
0 siblings, 2 replies; 5+ messages in thread
From: Wentao Liang @ 2026-09-17 13:22 UTC (permalink / raw)
To: Liviu.Dudau
Cc: bhelgaas, kwilczynski, linux-arm-kernel, linux-kernel, linux-pci,
lpieralisi, mani, robh, tinamdar, toan, Wentao Liang, stable
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@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()
2026-09-17 13:22 [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe() Wentao Liang
@ 2026-09-18 11:50 ` kernel test robot
2026-09-18 12:37 ` kernel test robot
1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-09-18 11:50 UTC (permalink / raw)
To: Wentao Liang, Liviu.Dudau
Cc: llvm, oe-kbuild-all, bhelgaas, kwilczynski, linux-arm-kernel,
linux-kernel, linux-pci, lpieralisi, mani, robh, tinamdar, toan,
Wentao Liang, stable
Hi Wentao,
kernel test robot noticed the following build errors:
[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus linus/master v7.3-rc3 next-20260916]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Wentao-Liang/PCI-xgene-Fix-device-node-reference-leak-in-xgene_pcie_probe/20260917-132235
base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link: https://lore.kernel.org/r/20260917132235.2153154-1-vulab%40iscas.ac.cn
patch subject: [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()
config: riscv-randconfig-1001-20260918 (https://download.01.org/0day-ci/archive/20260918/202609181924.6ZUpd4Ww-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 7252edd9aa82ef1c570ff6694ef7f4763a8a5d2f)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260918/202609181924.6ZUpd4Ww-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609181924.6ZUpd4Ww-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/pci/controller/pci-xgene.c:646:20: error: no member named 'node' in 'struct xgene_pcie'
646 | of_node_put(port->node);
| ~~~~ ^
1 error generated.
vim +646 drivers/pci/controller/pci-xgene.c
603
604 static int xgene_pcie_probe(struct platform_device *pdev)
605 {
606 struct device *dev = &pdev->dev;
607 struct xgene_pcie *port;
608 struct pci_host_bridge *bridge;
609 int ret;
610
611 if (!xgene_check_pcie_msi_ready())
612 return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
613 "MSI driver not ready\n");
614
615 bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port));
616 if (!bridge)
617 return -ENOMEM;
618
619 port = pci_host_bridge_priv(bridge);
620
621 port->dev = dev;
622 port->version = XGENE_PCIE_IP_VER_1;
623
624 ret = xgene_pcie_map_reg(port, pdev);
625 if (ret)
626 goto err_put_node;
627
628 ret = xgene_pcie_init_port(port);
629 if (ret)
630 goto err_put_node;
631
632 ret = xgene_pcie_setup(port);
633 if (ret)
634 goto err_put_node;
635
636 bridge->sysdata = port;
637 bridge->ops = &xgene_pcie_ops;
638
639 ret = pci_host_probe(bridge);
640 if (ret)
641 goto err_put_node;
642
643 return 0;
644
645 err_put_node:
> 646 of_node_put(port->node);
647 return ret;
648 }
649
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()
2026-09-17 13:22 [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe() Wentao Liang
2026-09-18 11:50 ` kernel test robot
@ 2026-09-18 12:37 ` kernel test robot
1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-09-18 12:37 UTC (permalink / raw)
To: Wentao Liang, Liviu.Dudau
Cc: oe-kbuild-all, bhelgaas, kwilczynski, linux-arm-kernel,
linux-kernel, linux-pci, lpieralisi, mani, robh, tinamdar, toan,
Wentao Liang, stable
Hi Wentao,
kernel test robot noticed the following build errors:
[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus linus/master v7.3-rc3 next-20260916]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Wentao-Liang/PCI-xgene-Fix-device-node-reference-leak-in-xgene_pcie_probe/20260917-132235
base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link: https://lore.kernel.org/r/20260917132235.2153154-1-vulab%40iscas.ac.cn
patch subject: [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20260918/202609182039.WWGUVgS7-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260918/202609182039.WWGUVgS7-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609182039.WWGUVgS7-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/pci/controller/pci-xgene.c: In function 'xgene_pcie_probe':
>> drivers/pci/controller/pci-xgene.c:646:25: error: 'struct xgene_pcie' has no member named 'node'
646 | of_node_put(port->node);
| ^~
vim +646 drivers/pci/controller/pci-xgene.c
603
604 static int xgene_pcie_probe(struct platform_device *pdev)
605 {
606 struct device *dev = &pdev->dev;
607 struct xgene_pcie *port;
608 struct pci_host_bridge *bridge;
609 int ret;
610
611 if (!xgene_check_pcie_msi_ready())
612 return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
613 "MSI driver not ready\n");
614
615 bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port));
616 if (!bridge)
617 return -ENOMEM;
618
619 port = pci_host_bridge_priv(bridge);
620
621 port->dev = dev;
622 port->version = XGENE_PCIE_IP_VER_1;
623
624 ret = xgene_pcie_map_reg(port, pdev);
625 if (ret)
626 goto err_put_node;
627
628 ret = xgene_pcie_init_port(port);
629 if (ret)
630 goto err_put_node;
631
632 ret = xgene_pcie_setup(port);
633 if (ret)
634 goto err_put_node;
635
636 bridge->sysdata = port;
637 bridge->ops = &xgene_pcie_ops;
638
639 ret = pci_host_probe(bridge);
640 if (ret)
641 goto err_put_node;
642
643 return 0;
644
645 err_put_node:
> 646 of_node_put(port->node);
647 return ret;
648 }
649
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()
2026-08-14 13:41 Ruoyu Wang
@ 2026-09-10 12:23 ` Manivannan Sadhasivam
0 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2026-09-10 12:23 UTC (permalink / raw)
To: Ruoyu Wang
Cc: Toan Le, Lorenzo Pieralisi, Krzysztof Wilczyński,
Rob Herring, Bjorn Helgaas, Liviu Dudau, Tanmay Inamdar,
linux-pci, linux-arm-kernel, linux-kernel
On Fri, Aug 14, 2026 at 09:41:18PM +0800, Ruoyu Wang wrote:
> 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 <ruoyuw560@gmail.com>
This was fixed by commit, 4869db344e76 ("PCI: xgene: Drop unnecessary OF node
reference").
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe()
@ 2026-08-14 13:41 Ruoyu Wang
2026-09-10 12:23 ` Manivannan Sadhasivam
0 siblings, 1 reply; 5+ messages in thread
From: Ruoyu Wang @ 2026-08-14 13:41 UTC (permalink / raw)
To: Toan Le, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Liviu Dudau,
Tanmay Inamdar
Cc: linux-pci, linux-arm-kernel, linux-kernel, Ruoyu Wang
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 <ruoyuw560@gmail.com>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-18 12:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 13:22 [PATCH] PCI: xgene: Fix device node reference leak in xgene_pcie_probe() Wentao Liang
2026-09-18 11:50 ` kernel test robot
2026-09-18 12:37 ` kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2026-08-14 13:41 Ruoyu Wang
2026-09-10 12:23 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®