All of lore.kernel.org
 help / color / mirror / Atom feed
* [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
                   ` (2 more replies)
  0 siblings, 3 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 leak in ls_g4_pcie_probe() Vishal Satle
@ 2026-10-27  9:49 ` sashiko-bot
  2026-11-05 14:14 ` Manivannan Sadhasivam
  2026-11-18  9:37 ` [PATCH v2] PCI: mobiveil: Drop unnecessary msi-parent check " Vishal Satle
  2 siblings, 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 leak in ls_g4_pcie_probe() Vishal Satle
  2026-10-27  9:49 ` sashiko-bot
@ 2026-11-05 14:14 ` Manivannan Sadhasivam
  2026-11-18  9:37 ` [PATCH v2] PCI: mobiveil: Drop unnecessary msi-parent check " Vishal Satle
  2 siblings, 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 v2] PCI: mobiveil: Drop unnecessary msi-parent check in ls_g4_pcie_probe()
  2026-10-27  9:44 [PATCH] PCI: mobiveil: Fix device_node leak in ls_g4_pcie_probe() Vishal Satle
  2026-10-27  9:49 ` sashiko-bot
  2026-11-05 14:14 ` Manivannan Sadhasivam
@ 2026-11-18  9:37 ` Vishal Satle
  2026-11-18  9:45   ` sashiko-bot
  2 siblings, 1 reply; 5+ messages in thread
From: Vishal Satle @ 2026-11-18  9:37 UTC (permalink / raw)
  To: Hou Zhiqiang, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam
  Cc: Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, linux-pci,
	linux-arm-kernel, linux-kernel, Vishal Satle, stable

ls_g4_pcie_probe() calls of_parse_phandle(np, "msi-parent", 0) solely as
a boolean existence check without releasing the returned device_node via
of_node_put(), leaking a reference count on probe.

Instead of keeping the check with of_node_put(), drop the check
altogether. The driver does not use the phandle directly (the irqchip
layer handles it), other PCI controller drivers do not enforce this
check, and without "msi-parent" INTx still works even though MSIs will
not, so probing does not need to fail.

Also remove the now-unused local variable np.

Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Vishal Satle <vishalsatleit24@gmail.com>
---
Changes in v2:
- Drop the msi-parent check and the now-unused np variable altogether
  instead of adding of_node_put(), as suggested by Manivannan.
- Link to v1: https://lore.kernel.org/all/20261027094427.143733-1-vishalsatleit24@gmail.com/

 drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c b/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
index 4919b27ea..f31be6327 100644
--- a/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
+++ b/drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
@@ -198,14 +198,8 @@ 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;
 	int ret;
 
-	if (!of_parse_phandle(np, "msi-parent", 0)) {
-		dev_err(dev, "Failed to find msi-parent\n");
-		return -EINVAL;
-	}
-
 	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
 	if (!bridge)
 		return -ENOMEM;
-- 
2.53.0


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

* Re: [PATCH v2] PCI: mobiveil: Drop unnecessary msi-parent check in ls_g4_pcie_probe()
  2026-11-18  9:37 ` [PATCH v2] PCI: mobiveil: Drop unnecessary msi-parent check " Vishal Satle
@ 2026-11-18  9:45   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-18  9:45 UTC (permalink / raw)
  To: Vishal Satle; +Cc: linux-pci

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] PCI: mobiveil: missing Fixes trailer for device_node leak in
  ls_g4_pcie_probe()
--

commit f42a1868186c1406c426daa13adc92dc71419de8
Author: Vishal Satle <vishalsatleit24@gmail.com>

> PCI: mobiveil: Drop unnecessary msi-parent check in ls_g4_pcie_probe()
>
> ls_g4_pcie_probe() calls of_parse_phandle(np, "msi-parent", 0) solely as
> a boolean existence check without releasing the returned device_node via
> of_node_put(), leaking a reference count on probe.
>
> Instead of keeping the check with of_node_put(), drop the check
> altogether. The driver does not use the phandle directly (the irqchip
> layer handles it), other PCI controller drivers do not enforce this
> check, and without "msi-parent" INTx still works even though MSIs will
> not, so probing does not need to fail.
>
> Also remove the now-unused local variable np.
>
> Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Vishal Satle <vishalsatleit24@gmail.com>

[Severity: Low]
Since this fixes the device_node reference count leak in
ls_g4_pcie_probe(), should this include:

  Fixes: d29ad70a813b ("PCI: mobiveil: Add PCIe Gen4 RC driver for Layerscape SoCs")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118093731.43980-1-vishalsatleit24@gmail.com?part=1

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

end of thread, other threads:[~2026-11-18  9:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27  9:44 [PATCH] PCI: mobiveil: Fix device_node leak in ls_g4_pcie_probe() Vishal Satle
2026-10-27  9:49 ` sashiko-bot
2026-11-05 14:14 ` Manivannan Sadhasivam
2026-11-18  9:37 ` [PATCH v2] PCI: mobiveil: Drop unnecessary msi-parent check " Vishal Satle
2026-11-18  9:45   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.