]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: imx6: Fix device node reference leak in imx_pcie_probe()
authorFelix Gu <ustc.gu@gmail.com>
Sat, 24 Jan 2026 15:42:45 +0000 (23:42 +0800)
committerManivannan Sadhasivam <mani@kernel.org>
Thu, 26 Feb 2026 06:48:22 +0000 (12:18 +0530)
In imx_pcie_probe(), of_parse_phandle() returns the device node pointer
with increased refcount. The pointer reference must be dropped by the
caller when it's no longer needed. However, imx_pcie_probe() doesn't drop
the reference, causing reference leak.

Fix this by using the __free(device_node) cleanup handler to drop the
reference when the function goes out of scope.

Fixes: 1df82ec46600 ("PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
[mani: commit log]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Acked-by: Richard Zhu <hongxing.zhu@nxp.com>
Link: https://patch.msgid.link/20260124-pci_imx6-v2-1-acb8d5187683@gmail.com
drivers/pci/controller/dwc/pci-imx6.c

index a5b8d0b71677e052b3c6898f20cacd9598a3b17a..81a7093494c85441b38a982b2cafbb6e6f298ec7 100644 (file)
@@ -1647,7 +1647,6 @@ static int imx_pcie_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct dw_pcie *pci;
        struct imx_pcie *imx_pcie;
-       struct device_node *np;
        struct device_node *node = dev->of_node;
        int i, ret, domain;
        u16 val;
@@ -1674,7 +1673,8 @@ static int imx_pcie_probe(struct platform_device *pdev)
                pci->pp.ops = &imx_pcie_host_dw_pme_ops;
 
        /* Find the PHY if one is defined, only imx7d uses it */
-       np = of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0);
+       struct device_node *np __free(device_node) =
+               of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0);
        if (np) {
                struct resource res;