All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuho Choi <oss.patchbox@gmail.com>
To: Marek Vasut <marek.vasut+usb@mailbox.org>
Cc: Stephan Gerhold <stephan@gerhold.net>,
	Linus Walleij <linusw@kernel.org>,
	Greg Malysa <malysagreg@gmail.com>,
	Vasileios Bimpikas <vasileios.bimpikas@analog.com>,
	Arturs Artamonovs <arturs.artamonovs@analog.com>,
	linux@analog.com, Tom Rini <trini@konsulko.com>,
	u-boot@lists.u-boot-project.org,
	Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH 6/6] usb: musb-new: da8xx: Free the controller if the host probe fails
Date: Fri,  6 Nov 2026 14:45:58 -0500	[thread overview]
Message-ID: <20261106194621.510146-7-oss.patchbox@gmail.com> (raw)
In-Reply-To: <20261106194621.510146-1-oss.patchbox@gmail.com>

da8xx_musb_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 error path turns off the PHY and the PSC but
does not free the struct musb, 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: 5608331d8136 ("usb: musb-new: Add support for da8xx-musb")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Build-tested only, with omapl138_lcdk_defconfig.

da8xx_musb_remove() does not free the struct musb either; that is not
changed here.

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

diff --git a/drivers/usb/musb-new/da8xx.c b/drivers/usb/musb-new/da8xx.c
index 7caf03cc2e1..17a953c9744 100644
--- a/drivers/usb/musb-new/da8xx.c
+++ b/drivers/usb/musb-new/da8xx.c
@@ -319,6 +319,8 @@ static int da8xx_musb_probe(struct udevice *dev)
 
 	if (ret == 0)
 		return 0;
+
+	free(host->host);
 shutdown:
 	/* Turn off the phy if we fail */
 	generic_phy_power_off(&plat->phy);
-- 
2.43.0


  parent reply	other threads:[~2026-11-06 21:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 19:45 [PATCH 0/6] usb: musb-new: Free the controller if the host probe fails Yuho Choi
2026-11-06 19:45 ` [PATCH 1/6] usb: musb-new: ux500: " Yuho Choi
2026-11-06 21:44   ` Linus Walleij
2026-11-06 19:45 ` [PATCH 2/6] usb: musb-new: sc5xx: " Yuho Choi
2026-11-07 23:18   ` Greg Malysa
2026-11-07 23:46     ` Greg Malysa
2026-11-08  3:20       ` Yuho Choi
2026-11-08  5:39         ` Greg Malysa
2026-11-06 19:45 ` [PATCH 3/6] usb: musb-new: pic32: " Yuho Choi
2026-11-06 19:45 ` [PATCH 4/6] usb: musb-new: omap2430: " Yuho Choi
2026-11-06 19:45 ` [PATCH 5/6] usb: musb-new: ti-musb: " Yuho Choi
2026-11-06 19:45 ` Yuho Choi [this message]
2026-11-06 20:56 ` [PATCH 0/6] usb: musb-new: " Tom Rini
2026-11-06 23:19   ` Yuho Choi
2026-11-09 17:29     ` Tom Rini
2026-11-09 20:41       ` Yuho Choi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106194621.510146-7-oss.patchbox@gmail.com \
    --to=oss.patchbox@gmail.com \
    --cc=arturs.artamonovs@analog.com \
    --cc=linusw@kernel.org \
    --cc=linux@analog.com \
    --cc=malysagreg@gmail.com \
    --cc=marek.vasut+usb@mailbox.org \
    --cc=stephan@gerhold.net \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=vasileios.bimpikas@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.