linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: imx: fix device node reference leak in imx_pcie_probe
@ 2025-09-03 13:51 Miaoqian Lin
  2025-09-03 17:10 ` Markus Elfring
  2025-09-03 18:31 ` Frank Li
  0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2025-09-03 13:51 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, linux-pci, linux-arm-kernel, imx,
	linux-kernel
  Cc: linmq006, stable

As the doc of of_parse_phandle() states:
"The device_node pointer with refcount incremented.  Use
 * of_node_put() on it when done."
Add missing of_node_put() after of_parse_phandle() call to properly
release the device node reference.

Found via static analysis.

Fixes: 1df82ec46600 ("PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/pci/controller/dwc/pci-imx6.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 80e48746bbaf..618bc4b08a8b 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -1636,6 +1636,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
 		struct resource res;
 
 		ret = of_address_to_resource(np, 0, &res);
+		of_node_put(np);
 		if (ret) {
 			dev_err(dev, "Unable to map PCIe PHY\n");
 			return ret;
-- 
2.35.1


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

* Re: [PATCH] PCI: imx: fix device node reference leak in imx_pcie_probe
  2025-09-03 13:51 [PATCH] PCI: imx: fix device node reference leak in imx_pcie_probe Miaoqian Lin
@ 2025-09-03 17:10 ` Markus Elfring
  2025-09-03 18:31 ` Frank Li
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-09-03 17:10 UTC (permalink / raw)
  To: Miaoqian Lin, imx, linux-pci, linux-arm-kernel, kernel
  Cc: stable, LKML, Bjorn Helgaas, Fabio Estevam,
	Krzysztof Wilczyński, Lorenzo Pieralisi, Lucas Stach,
	Manivannan Sadhasivam, Rob Herring, Richard Zhu, Sascha Hauer,
	Shawn Guo, Trent Piepho

> Add missing of_node_put() after of_parse_phandle() call to properly
> release the device node reference.

How do you think about to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v6.17-rc4/source/include/linux/of.h#L138


> Found via static analysis.

Which concrete software tools would be involved for this purpose?


How do you think about to append parentheses to the function name
in the summary phrase?

Regards,
Markus

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

* Re: [PATCH] PCI: imx: fix device node reference leak in imx_pcie_probe
  2025-09-03 13:51 [PATCH] PCI: imx: fix device node reference leak in imx_pcie_probe Miaoqian Lin
  2025-09-03 17:10 ` Markus Elfring
@ 2025-09-03 18:31 ` Frank Li
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2025-09-03 18:31 UTC (permalink / raw)
  To: Miaoqian Lin
  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, stable

On Wed, Sep 03, 2025 at 09:51:50PM +0800, Miaoqian Lin wrote:

Subject: PCI: imx: Add missing of_node_put() to fix device node reference leak

> As the doc of of_parse_phandle() states:
> "The device_node pointer with refcount incremented.  Use
>  * of_node_put() on it when done."

Needn't this paragaph

Frank
> Add missing of_node_put() after of_parse_phandle() call to properly
> release the device node reference.
>
> Found via static analysis.
>
> Fixes: 1df82ec46600 ("PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 80e48746bbaf..618bc4b08a8b 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -1636,6 +1636,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
>  		struct resource res;
>
>  		ret = of_address_to_resource(np, 0, &res);
> +		of_node_put(np);
>  		if (ret) {
>  			dev_err(dev, "Unable to map PCIe PHY\n");
>  			return ret;
> --
> 2.35.1
>

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

end of thread, other threads:[~2025-09-03 18:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 13:51 [PATCH] PCI: imx: fix device node reference leak in imx_pcie_probe Miaoqian Lin
2025-09-03 17:10 ` Markus Elfring
2025-09-03 18:31 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).