All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: musb-new: mt85xx: Free the controller if the host probe fails
@ 2026-11-06 19:37 Yuho Choi
  2026-11-06 20:52 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-11-06 19:37 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Tom Rini, u-boot, Yuho Choi

In host mode, musb_usb_probe() allocates the struct musb with
musb_init_controller() and returns the error when musb_lowlevel_init()
fails, for example when no device is connected. The struct musb is not
freed on this path, and the driver core then frees the private data that
holds the only pointer to it. Each 'usb reset', or 'usb start' after
'usb stop', probes the controller again and leaks another one.

Free the struct musb when musb_lowlevel_init() fails.

Fixes: 7d017d607eaa ("usb: musb-new: mt85xx: add musb-new gadget driver.")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Build-tested only, with mt8518_ap1_emmc_defconfig and
CONFIG_USB_MUSB_HOST=y.

 drivers/usb/musb-new/mt85xx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/musb-new/mt85xx.c b/drivers/usb/musb-new/mt85xx.c
index 14b28bbae6b..2e13b2a30d8 100644
--- a/drivers/usb/musb-new/mt85xx.c
+++ b/drivers/usb/musb-new/mt85xx.c
@@ -365,6 +365,8 @@ static int musb_usb_probe(struct udevice *dev)
 	ret = musb_lowlevel_init(host);
 	if (!ret)
 		printf("MTK MUSB OTG (Host)\n");
+	else
+		free(host->host);
 #else
 	pdata.mode = MUSB_PERIPHERAL;
 	host->host = musb_register(&pdata, &glue->dev, base);

base-commit: feb8913982e4462c01fd914271f92254a25dc101
-- 
2.43.0


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

end of thread, other threads:[~2026-11-06 21:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 19:37 [PATCH] usb: musb-new: mt85xx: Free the controller if the host probe fails Yuho Choi
2026-11-06 20:52 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.