public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: musb: ux500: Fix PHY resource leak in error path
@ 2025-11-03  2:02 Haotian Zhang
  2025-11-03  2:07 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Haotian Zhang @ 2025-11-03  2:02 UTC (permalink / raw)
  To: Bin Liu, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel, Haotian Zhang

The ux500_musb_init() function calls usb_get_phy() to obtain a PHY
resource, but fails to release it with usb_put_phy() when
usb_register_notifier() fails. This leads to a resource leak as the
PHY reference count is not properly decremented.

Add usb_put_phy() call in the error path before returning to ensure
the PHY resource is properly released when notifier registration fails.

Fixes: 0135522c4898 ("usb: musb: ux500: add otg notifier support")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/usb/musb/ux500.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 8c2a43d992f5..14c5e986937e 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -155,6 +155,7 @@ static int ux500_musb_init(struct musb *musb)
 	status = usb_register_notifier(musb->xceiv, &musb->nb);
 	if (status < 0) {
 		dev_dbg(musb->controller, "notification register failed\n");
+		usb_put_phy(musb->xceiv);
 		return status;
 	}
 
-- 
2.50.1.windows.1


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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-03  2:02 [PATCH] usb: musb: ux500: Fix PHY resource leak in error path Haotian Zhang
2025-11-03  2:07 ` Greg Kroah-Hartman

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