* [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe()
@ 2026-01-24 15:42 Felix Gu
2026-01-24 20:24 ` Bjorn Helgaas
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Felix Gu @ 2026-01-24 15:42 UTC (permalink / raw)
To: Richard Zhu, Lucas Stach, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Trent Piepho
Cc: linux-pci, linux-arm-kernel, imx, linux-kernel, Felix Gu
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@gmail.com>
---
Changes in v2:
- Use __free(device_node) clean handler to fix the leak.
- Link to v1: https://lore.kernel.org/r/20260124-pci_imx6-v1-1-6f4379fc5160@gmail.com
---
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@gmail.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe()
2026-01-24 15:42 [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe() Felix Gu
@ 2026-01-24 20:24 ` Bjorn Helgaas
2026-01-26 7:13 ` Hongxing Zhu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2026-01-24 20:24 UTC (permalink / raw)
To: Felix Gu
Cc: Richard Zhu, Lucas Stach, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Trent Piepho, linux-pci, linux-arm-kernel, imx,
linux-kernel
On Sat, Jan 24, 2026 at 11:42:45PM +0800, Felix Gu wrote:
> 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.
Mani, if you apply this, can you add a blank line between paragraphs
and:
s/imx_pcie_probe,/imx_pcie_probe(),/
s/cuases/causes/
Felix, if you repost this for other reasons, please incorporate those.
> Fixes: 1df82ec46600 ("PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
> Changes in v2:
> - Use __free(device_node) clean handler to fix the leak.
> - Link to v1: https://lore.kernel.org/r/20260124-pci_imx6-v1-1-6f4379fc5160@gmail.com
> ---
> 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@gmail.com>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe()
2026-01-24 15:42 [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe() Felix Gu
2026-01-24 20:24 ` Bjorn Helgaas
@ 2026-01-26 7:13 ` Hongxing Zhu
2026-01-26 17:49 ` Frank Li
2026-02-26 6:46 ` Manivannan Sadhasivam
3 siblings, 0 replies; 5+ messages in thread
From: Hongxing Zhu @ 2026-01-26 7:13 UTC (permalink / raw)
To: Felix Gu, Lucas Stach, Lorenzo Pieralisi,
Krzysztof Wilczy��ski, Manivannan Sadhasivam,
Rob Herring, Bjorn Helgaas, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Trent Piepho
Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
imx@lists.linux.dev, linux-kernel@vger.kernel.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 3292 bytes --]
> -----Original Message-----
> From: Felix Gu <ustc.gu@gmail.com>
> Sent: 2026Äê1ÔÂ24ÈÕ 23:43
> To: Hongxing Zhu <hongxing.zhu@nxp.com>; Lucas Stach
> <l.stach@pengutronix.de>; Lorenzo Pieralisi <lpieralisi@kernel.org>;
> Krzysztof Wilczy¨½ski <kwilczynski@kernel.org>; Manivannan Sadhasivam
> <mani@kernel.org>; Rob Herring <robh@kernel.org>; Bjorn Helgaas
> <bhelgaas@google.com>; Shawn Guo <shawnguo@kernel.org>; Sascha
> Hauer <s.hauer@pengutronix.de>; Pengutronix Kernel Team
> <kernel@pengutronix.de>; Fabio Estevam <festevam@gmail.com>; Trent
> Piepho <tpiepho@impinj.com>
> Cc: linux-pci@vger.kernel.org; linux-arm-kernel@lists.infradead.org;
> imx@lists.linux.dev; linux-kernel@vger.kernel.org; Felix Gu
> <ustc.gu@gmail.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@gmail.com>
Acked-by: Richard Zhu <hongxing.zhu@nxp.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@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe()
2026-01-24 15:42 [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe() Felix Gu
2026-01-24 20:24 ` Bjorn Helgaas
2026-01-26 7:13 ` Hongxing Zhu
@ 2026-01-26 17:49 ` Frank Li
2026-02-26 6:46 ` Manivannan Sadhasivam
3 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2026-01-26 17:49 UTC (permalink / raw)
To: Felix Gu
Cc: Richard Zhu, Lucas Stach, Lorenzo Pieralisi,
Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
Bjorn Helgaas, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Trent Piepho, linux-pci, linux-arm-kernel, imx,
linux-kernel
On Sat, Jan 24, 2026 at 11:42:45PM +0800, Felix Gu wrote:
> 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@gmail.com>
> ---
After fix Bjons's comments.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Changes in v2:
> - Use __free(device_node) clean handler to fix the leak.
> - Link to v1: https://lore.kernel.org/r/20260124-pci_imx6-v1-1-6f4379fc5160@gmail.com
> ---
> 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@gmail.com>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe()
2026-01-24 15:42 [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe() Felix Gu
` (2 preceding siblings ...)
2026-01-26 17:49 ` Frank Li
@ 2026-02-26 6:46 ` Manivannan Sadhasivam
3 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2026-02-26 6:46 UTC (permalink / raw)
To: Richard Zhu, Lucas Stach, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Trent Piepho, Felix Gu
Cc: linux-pci, linux-arm-kernel, imx, linux-kernel
On Sat, 24 Jan 2026 23:42:45 +0800, Felix Gu wrote:
> 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.
>
>
> [...]
Applied, thanks!
[1/1] PCI: imx6: Fix device node reference leak in imx_pcie_probe()
commit: 4836ad727486563370b213ef594d644d1bf85b8d
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-26 6:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-24 15:42 [PATCH v2] PCI: imx6: Fix device node reference leak in imx_pcie_probe() Felix Gu
2026-01-24 20:24 ` Bjorn Helgaas
2026-01-26 7:13 ` Hongxing Zhu
2026-01-26 17:49 ` Frank Li
2026-02-26 6:46 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox