Re: [PATCH] PCI: mobiveil: Fix device_node leak in ls_g4_pcie_probe()

From: Manivannan Sadhasivam

Date: Thu Nov 05 2026 - 09:20:57 EST


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@xxxxxxxxxxxxxxx
>

Why? This is not a critical bug fix to backport.

> Signed-off-by: Vishal Satle <vishalsatleit24@xxxxxxxxx>
> ---
> 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