[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<AS8PR04MB8833845E3436CFE30EDEC2E98C93A@AS8PR04MB8833.eurprd04.prod.outlook.com>
Date: Mon, 26 Jan 2026 07:13:19 +0000
From: Hongxing Zhu <hongxing.zhu@....com>
To: Felix Gu <ustc.gu@...il.com>, Lucas Stach <l.stach@...gutronix.de>,
Lorenzo Pieralisi <lpieralisi@...nel.org>,
Krzysztof Wilczy��ski <kwilczynski@...nel.org>,
Manivannan Sadhasivam <mani@...nel.org>, Rob Herring <robh@...nel.org>, Bjorn
Helgaas <bhelgaas@...gle.com>, Shawn Guo <shawnguo@...nel.org>, Sascha Hauer
<s.hauer@...gutronix.de>, Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Trent Piepho <tpiepho@...inj.com>
CC: "linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "imx@...ts.linux.dev"
<imx@...ts.linux.dev>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2] PCI: imx6: Fix device node reference leak in
imx_pcie_probe()
> -----Original Message-----
> From: Felix Gu <ustc.gu@...il.com>
> Sent: 2026年1月24日 23:43
> To: Hongxing Zhu <hongxing.zhu@....com>; Lucas Stach
> <l.stach@...gutronix.de>; Lorenzo Pieralisi <lpieralisi@...nel.org>;
> Krzysztof Wilczy��ski <kwilczynski@...nel.org>; Manivannan Sadhasivam
> <mani@...nel.org>; Rob Herring <robh@...nel.org>; Bjorn Helgaas
> <bhelgaas@...gle.com>; Shawn Guo <shawnguo@...nel.org>; Sascha
> Hauer <s.hauer@...gutronix.de>; Pengutronix Kernel Team
> <kernel@...gutronix.de>; Fabio Estevam <festevam@...il.com>; Trent
> Piepho <tpiepho@...inj.com>
> Cc: linux-pci@...r.kernel.org; linux-arm-kernel@...ts.infradead.org;
> imx@...ts.linux.dev; linux-kernel@...r.kernel.org; Felix Gu
> <ustc.gu@...il.com>
> Subject: [PATCH v2] PCI: imx6: Fix device node reference leak in
> imx_pcie_probe()
>
> In imx_pcie_probe, np is obtained by of_parse_phandle() and must be
> released when it's no longer needed. However, it doesn't release the
> reference, which cuases a reference leak.
> Fix this by using the __free(device_node) cleanup handler to release the
> reference when it goes out of scope.
>
> Fixes: 1df82ec46600 ("PCI: imx: Add workaround for e10728, IMX7d PCIe PLL
> failure")
> Signed-off-by: Felix Gu <ustc.gu@...il.com>
Acked-by: Richard Zhu <hongxing.zhu@....com>
Hi Mani:
Please help to merge it after refine the commit refer to Bjorn's comments.
Thanks.
Best Regards
Richard Zhu
> ---
> Changes in v2:
> - Use __free(device_node) clean handler to fix the leak.
> - Link to v1:
> https://lore.ke/
> rnel.org%2Fr%2F20260124-pci_imx6-v1-1-6f4379fc5160%40gmail.com&data=
> 05%7C02%7Chongxing.zhu%40nxp.com%7Cf489385f9bdc4c71508908de5b67
> 727e%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6390486970205
> 66603%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIw
> LjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%
> 7C%7C%7C&sdata=mJZl3iAqX71BeptkhNGzeP3eElGRUDnBhYabt265vqs%3D&r
> eserved=0
> ---
> drivers/pci/controller/dwc/pci-imx6.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c
> b/drivers/pci/controller/dwc/pci-imx6.c
> index 1d8677d7de04..f459d05ecd7d 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -1643,7 +1643,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;
> @@ -1670,7 +1669,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;
>
>
> ---
> base-commit: a0c666c25aeefd16f4b088c6549a6fb6b65a8a1d
> change-id: 20260124-pci_imx6-f97d70887dfc
>
> Best regards,
> --
> Felix Gu <ustc.gu@...il.com>
Powered by blists - more mailing lists