Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: mobiveil: fix device node leak in ls_g4_pcie_probe()
@ 2026-12-03  3:56 Yuwei Chen
  2026-12-03  3:58 ` sashiko-bot
  0 siblings, 1 reply; 5+ messages in thread
From: Yuwei Chen @ 2026-12-03  3:56 UTC (permalink / raw)
  To: Hou Zhiqiang; +Cc: Bjorn Helgaas, linux-pci, linux-arm-kernel

ls_g4_pcie_probe() calls of_parse_phandle() on "msi-parent" and uses
the result only as a NULL check. The node itself is discarded, so every
successful lookup leaks the reference.

Drop it after the check.

Fixes: d29ad70a813b ("PCI: mobiveil: Add PCIe Gen4 RC driver for Layerscape SoCs")
Cc: stable@vger.kernel.org
Signed-off-by: Yuwei Chen <2522445001@qq.com>
---
 drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c b/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
index 4919b27eaf44..4919b27eaf44 100644
--- a/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
+++ b/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
@@ -198,13 +198,15 @@ static int __init ls_g4_pcie_probe(struct platform_device *pdev)
 	struct pci_host_bridge *bridge;
 	struct mobiveil_pcie *mv_pci;
 	struct ls_g4_pcie *pcie;
-	struct device_node *np = dev->of_node;
+	struct device_node *np = dev->of_node, *msi_np;
 	int ret;
 
-	if (!of_parse_phandle(np, "msi-parent", 0)) {
+	msi_np = of_parse_phandle(np, "msi-parent", 0);
+	if (!msi_np) {
 		dev_err(dev, "Failed to find msi-parent\n");
 		return -EINVAL;
 	}
+	of_node_put(msi_np);
 
 	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
 	if (!bridge)
-- 
2.53.0.windows.2

base-commit: 3dbdc13bd4b313b3d94c0f719378a4641a39db46


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] PCI: mobiveil: Fix device_node leak in ls_g4_pcie_probe()
@ 2026-10-27  9:44 Vishal Satle
  2026-10-27  9:49 ` sashiko-bot
  2026-11-05 14:14 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 5+ messages in thread
From: Vishal Satle @ 2026-10-27  9:44 UTC (permalink / raw)
  To: Hou Zhiqiang, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Bjorn Helgaas
  Cc: Rob Herring, linux-pci, linux-arm-kernel, linux-kernel, stable,
	Vishal Satle

ls_g4_pcie_probe() calls of_parse_phandle() to verify the presence of
the "msi-parent" device node. of_parse_phandle() increments the reference
count of the returned device_node.

Because the return value was evaluated directly as a boolean condition,
the acquired reference was never released, leaking the MSI controller node
reference count on probe.

Assign the resolved node to a local variable and call of_node_put() once
the existence check is complete.

Cc: stable@vger.kernel.org

Signed-off-by: Vishal Satle <vishalsatleit24@gmail.com>
---
 drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c b/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
index 4919b27ea..5b1862fe0 100644
--- a/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
+++ b/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
@@ -199,12 +199,15 @@ static int __init ls_g4_pcie_probe(struct platform_device *pdev)
 	struct mobiveil_pcie *mv_pci;
 	struct ls_g4_pcie *pcie;
 	struct device_node *np = dev->of_node;
+	struct device_node *msi_node;
 	int ret;
 
-	if (!of_parse_phandle(np, "msi-parent", 0)) {
+	msi_node = of_parse_phandle(np, "msi-parent", 0);
+	if (!msi_node) {
 		dev_err(dev, "Failed to find msi-parent\n");
 		return -EINVAL;
 	}
+	of_node_put(msi_node);
 
 	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
 	if (!bridge)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-03  3:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  3:56 [PATCH] PCI: mobiveil: fix device node leak in ls_g4_pcie_probe() Yuwei Chen
2026-12-03  3:58 ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-10-27  9:44 [PATCH] PCI: mobiveil: Fix device_node " Vishal Satle
2026-10-27  9:49 ` sashiko-bot
2026-11-05 14:14 ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox