Linux Tegra architecture development
 help / color / mirror / Atom feed
* [PATCH] phy: tegra: xusb-tegra210: Fix reference leaks in tegra210_xusb_padctl_probe
@ 2025-09-03  4:52 Miaoqian Lin
  2025-09-03 11:21 ` Markus Elfring
  2025-09-03 15:11 ` Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2025-09-03  4:52 UTC (permalink / raw)
  To: JC Kuo, Vinod Koul, Kishon Vijay Abraham I, Thierry Reding,
	Jonathan Hunter, linux-phy, linux-tegra, linux-kernel
  Cc: linmq006, stable

Add missing of_node_put() and put_device() calls to release references.

The function calls of_parse_phandle() and of_find_device_by_node()
but fails to release the references.
Both functions' documentation mentions that
the returned references must be dropped after use.

Found through static analysis by reviewing the documentation and
cross-checking their usage patterns.

Fixes: 2d1021487273 ("phy: tegra: xusb: Add wake/sleepwalk for Tegra210")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/phy/tegra/xusb-tegra210.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/tegra/xusb-tegra210.c b/drivers/phy/tegra/xusb-tegra210.c
index ebc8a7e21a31..cbfca51a53bc 100644
--- a/drivers/phy/tegra/xusb-tegra210.c
+++ b/drivers/phy/tegra/xusb-tegra210.c
@@ -3164,18 +3164,23 @@ tegra210_xusb_padctl_probe(struct device *dev,
 	}
 
 	pdev = of_find_device_by_node(np);
+	of_node_put(np);
 	if (!pdev) {
 		dev_warn(dev, "PMC device is not available\n");
 		goto out;
 	}
 
-	if (!platform_get_drvdata(pdev))
+	if (!platform_get_drvdata(pdev)) {
+		put_device(&pdev->dev);
 		return ERR_PTR(-EPROBE_DEFER);
+	}
 
 	padctl->regmap = dev_get_regmap(&pdev->dev, "usb_sleepwalk");
 	if (!padctl->regmap)
 		dev_info(dev, "failed to find PMC regmap\n");
 
+	put_device(&pdev->dev);
+
 out:
 	return &padctl->base;
 }
-- 
2.35.1


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

* Re: [PATCH] phy: tegra: xusb-tegra210: Fix reference leaks in tegra210_xusb_padctl_probe
  2025-09-03  4:52 [PATCH] phy: tegra: xusb-tegra210: Fix reference leaks in tegra210_xusb_padctl_probe Miaoqian Lin
@ 2025-09-03 11:21 ` Markus Elfring
  2025-09-03 15:11 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-09-03 11:21 UTC (permalink / raw)
  To: Miaoqian Lin, linux-tegra, linux-phy
  Cc: stable, LKML, JC Kuo, Jonathan Hunter, Kishon Vijay Abraham I,
	Thierry Reding, Vinod Koul

> Add missing of_node_put() and put_device() calls to release references.

How do you think about to increase the application of scope-based resource management?


…
> Found through static analysis by …

Which concrete software tools would be involved for this purpose?

Regards,
Markus

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

* Re: [PATCH] phy: tegra: xusb-tegra210: Fix reference leaks in tegra210_xusb_padctl_probe
  2025-09-03  4:52 [PATCH] phy: tegra: xusb-tegra210: Fix reference leaks in tegra210_xusb_padctl_probe Miaoqian Lin
  2025-09-03 11:21 ` Markus Elfring
@ 2025-09-03 15:11 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-09-03 15:11 UTC (permalink / raw)
  To: Miaoqian Lin, linux-tegra, linux-phy
  Cc: stable, LKML, JC Kuo, Johan Hovold, Jonathan Hunter,
	Kishon Vijay Abraham I, Neil Armstrong, Thierry Reding,
	Vinod Koul

> Add missing of_node_put() and put_device() calls to release references.

See also the commit bca065733afd1e3a89a02f05ffe14e966cd5f78e ("phy: tegra: xusb:
fix device and OF node leak at probe") by Johan Hovold.

Regards,
Markus

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03  4:52 [PATCH] phy: tegra: xusb-tegra210: Fix reference leaks in tegra210_xusb_padctl_probe Miaoqian Lin
2025-09-03 11:21 ` Markus Elfring
2025-09-03 15:11 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox