mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] phy: ti: omap-usb2: fix OF node leak at probe
@ 2026-11-09  7:24 Zhao Feng
  2026-11-18 19:20 ` Markus Elfring
  0 siblings, 1 reply; 4+ messages in thread
From: Zhao Feng @ 2026-11-09  7:24 UTC (permalink / raw)
  To: Vinod Koul, linux-phy
  Cc: Johan Hovold, Manivannan Sadhasivam, Miaoqian Lin, Guangshuo Li,
	linux-kernel, Zhao Feng

omap_usb2_probe() obtains a reference to the ctrl-module device node
with of_parse_phandle() and never drops it, on either the successful
path or the !control_pdev error path.

Drop the node reference right after of_find_device_by_node(); the
device reference taken by of_find_device_by_node() keeps the platform
device alive and is released at unbind by the devm action registered
below.

Fixes: 478b6c7436c2 ("usb: phy: omap-usb2: Don't use omap_get_control_dev()")
Signed-off-by: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
---
This is a resend of an identical one-line fix that stalled twice:

- Miaoqian Lin, 2025-10-28, with the same Fixes tag, which collected
  Reviewed-by: Johan Hovold <johan@kernel.org> with the only remark
  that Cc: stable should be dropped (done here), but was never applied:
  https://marc.info/?l=linux-kernel&m=176163256031244
- Guangshuo Li, 2026-07-08, which got review feedback from Manivannan
  Sadhasivam on 2026-09-26 (wrong Fixes tag, cut-off commit message)
  and was never respun:
  https://marc.info/?l=linux-kernel&m=178349844443656

Verified against current upstream master, which still leaks the
reference.  Not runtime-tested (no OMAP hardware).

 drivers/phy/ti/phy-omap-usb2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/phy/ti/phy-omap-usb2.c b/drivers/phy/ti/phy-omap-usb2.c
--- a/drivers/phy/ti/phy-omap-usb2.c
+++ b/drivers/phy/ti/phy-omap-usb2.c
@@ -427,6 +427,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
 		control_pdev = of_find_device_by_node(control_node);
+		of_node_put(control_node);
 		if (!control_pdev) {
 			dev_err(&pdev->dev, "Failed to get control device\n");
 			return -EINVAL;
 		}
-- 
2.39.2




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

* Re: [PATCH] phy: ti: omap-usb2: fix OF node leak at probe
  2026-11-09  7:24 [PATCH] phy: ti: omap-usb2: fix OF node leak at probe Zhao Feng
@ 2026-11-18 19:20 ` Markus Elfring
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2026-11-18 19:20 UTC (permalink / raw)
  To: Zhao Feng, linux-phy, Vinod Koul
  Cc: LKML, kernel-janitors, Guangshuo Li, Johan Hovold,
	Manivannan Sadhasivam, Miaoqian Lin

…
> Drop the node reference right after of_find_device_by_node(); the
> device reference taken by of_find_device_by_node() keeps the platform
> device alive and is released at unbind by the devm action registered
> below.

How do you think about to reduce also the scope for the corresponding local
variable “control_node”?
https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/phy/ti/phy-omap-usb2.c#L373-L515

Would you eventually like to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v7.4-rc1/source/include/linux/of.h#L138

Regards,
Markus


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

* Re: [PATCH] phy: ti: omap-usb2: fix OF node leak at probe
  2026-07-08  8:12 Guangshuo Li
@ 2026-09-26 14:15 ` Manivannan Sadhasivam
  0 siblings, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2026-09-26 14:15 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Vinod Koul, Neil Armstrong, Johan Hovold, Kishon Vijay Abraham I,
	linux-phy, linux-kernel

On Wed, Jul 08, 2026 at 04:12:54PM +0800, Guangshuo Li wrote:
> omap_usb2_probe() parses the ctrl-module phandle and then looks up the
> corresponding platform device.
> 
> of_parse_phandle() returns a device node with a reference that must be
> dropped by the caller. The driver currently keeps the device reference
> taken by of_find_device_by_node() until unbind, but never drops the
> temporary OF node reference taken by of_parse_phandle().
> 
> Drop the OF node reference after of_find_device_by_node() has consumed
> the node. This covers both the successful lookup path and the

This sentence is abrubtly cut-off.

> 
> Fixes: 9955a7835bf3 ("phy: omap-usb2: use *syscon* framework API to power on/off the PHY")

This fixes tag looks wrong. It just uses the syscon API but the leak predates
that commit.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

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

* [PATCH] phy: ti: omap-usb2: fix OF node leak at probe
@ 2026-07-08  8:12 Guangshuo Li
  2026-09-26 14:15 ` Manivannan Sadhasivam
  0 siblings, 1 reply; 4+ messages in thread
From: Guangshuo Li @ 2026-07-08  8:12 UTC (permalink / raw)
  To: Vinod Koul, Neil Armstrong, Johan Hovold, Guangshuo Li,
	Kishon Vijay Abraham I, linux-phy, linux-kernel

omap_usb2_probe() parses the ctrl-module phandle and then looks up the
corresponding platform device.

of_parse_phandle() returns a device node with a reference that must be
dropped by the caller. The driver currently keeps the device reference
taken by of_find_device_by_node() until unbind, but never drops the
temporary OF node reference taken by of_parse_phandle().

Drop the OF node reference after of_find_device_by_node() has consumed
the node. This covers both the successful lookup path and the

Fixes: 9955a7835bf3 ("phy: omap-usb2: use *syscon* framework API to power on/off the PHY")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/phy/ti/phy-omap-usb2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/phy/ti/phy-omap-usb2.c b/drivers/phy/ti/phy-omap-usb2.c
index 1eb252604441..660df3181e4f 100644
--- a/drivers/phy/ti/phy-omap-usb2.c
+++ b/drivers/phy/ti/phy-omap-usb2.c
@@ -426,6 +426,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 		}
 
 		control_pdev = of_find_device_by_node(control_node);
+		of_node_put(control_node);
 		if (!control_pdev) {
 			dev_err(&pdev->dev, "Failed to get control device\n");
 			return -EINVAL;
-- 
2.43.0


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

end of thread, other threads:[~2026-11-18 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09  7:24 [PATCH] phy: ti: omap-usb2: fix OF node leak at probe Zhao Feng
2026-11-18 19:20 ` Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2026-07-08  8:12 Guangshuo Li
2026-09-26 14:15 ` Manivannan Sadhasivam

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

all inboxes | Powered by JetHome®