* [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
* Re: [PATCH] PCI: mobiveil: Fix device_node leak in ls_g4_pcie_probe()
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
1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-10-27 9:49 UTC (permalink / raw)
To: Vishal Satle; +Cc: linux-pci
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027094427.143733-1-vishalsatleit24@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: mobiveil: Fix device_node leak in ls_g4_pcie_probe()
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
1 sibling, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2026-11-05 14:14 UTC (permalink / raw)
To: Vishal Satle
Cc: Hou Zhiqiang, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Bjorn Helgaas, Rob Herring, linux-pci,
linux-arm-kernel, linux-kernel, stable
On 2026-10-27 15:14 +0530, Vishal Satle wrote:
> 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
>
Why? This is not a critical bug fix to backport.
> 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) {
You should just use of_property_present() and be done with it. The driver is not
using the phandle and it shouldn't care if it resolves to a proper node or not
as it will be verified by the irqchip layer.
But that being said, I really doubt whether we need this check or not. None of
the other controller drivers are having this check. If this property is absent,
then MSIs won't work, but INTx will continue to work. So the controller wouldn't
be broken altogether.
So this check can be dropped.
- Mani
^ permalink raw reply [flat|nested] 5+ messages in thread
* [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
* Re: [PATCH] PCI: mobiveil: fix device node leak in ls_g4_pcie_probe()
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
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-03 3:58 UTC (permalink / raw)
To: Yuwei Chen; +Cc: linux-pci
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_ACBAB383CAF35D4851FC14E0EA5BB7649208@qq.com?part=1
^ permalink raw reply [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