Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: gadget: destroy connect_mutex after usb_del_gadget
@ 2026-11-23 20:13 Konrad Dybcio
  2026-11-23 20:30 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Konrad Dybcio @ 2026-11-23 20:13 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman; +Cc: linux-usb, usb4-upstream, Konrad Dybcio

usb_del_gadget() unbinds the function driver, which may still call
dwc3_gadget_pullup() and take connect_mutex. Destroying the mutex
before that point leaves a live lock behind during teardown.

Avoid it.

Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a76f669a796c2e0eb955969a88523affcb672ae2..673f4bffb8ca85778d084820ecfed49f50d1cac3 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -5027,9 +5027,9 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
 		return;
 
 	cancel_work_sync(&dwc->err_recovery_work);
-	mutex_destroy(&dwc->connect_mutex);
 	dwc3_enable_susphy(dwc, true);
 	usb_del_gadget(dwc->gadget);
+	mutex_destroy(&dwc->connect_mutex);
 	dwc3_gadget_free_endpoints(dwc);
 	usb_put_gadget(dwc->gadget);
 	dma_free_coherent(dwc->sysdev, DWC3_BOUNCE_SIZE, dwc->bounce,

---
base-commit: 749a4de370409464cf8501ec5b2451df45c84eb4
change-id: 20261123-topic-dwc3_gadget_fix-2d05048742cf

Best regards,
-- 
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>


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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 20:13 [PATCH] usb: dwc3: gadget: destroy connect_mutex after usb_del_gadget Konrad Dybcio
2026-11-23 20:30 ` sashiko-bot

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