ti_musb_host_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: ae6acf9fe2c8 ("drivers: usb: musb: add ti musb host driver with driver
model support")
Signed-off-by: Yuho Choi <[email protected]>
---
Build-tested only, with pcm051_rev3_defconfig.
ti_musb_host_remove() does not free the struct musb either, and the
PHY stays powered on after the failure; neither is changed here.
drivers/usb/musb-new/ti-musb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index cc6c3b94a65..5a93708bc75 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -168,6 +168,8 @@ static int ti_musb_host_probe(struct udevice *dev)
ti_musb_set_phy_power(dev, 1);
ret = musb_lowlevel_init(host);
+ if (ret)
+ free(host->host);
return ret;
}
--
2.43.0