Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: gadget: cancel NoStream work before endpoint teardown
@ 2026-08-07 18:23 Radhey Shyam Pandey
  2026-08-07 22:12 ` Thinh Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Radhey Shyam Pandey @ 2026-08-07 18:23 UTC (permalink / raw)
  To: Thinh.Nguyen, gregkh; +Cc: linux-usb, linux-kernel, Radhey Shyam Pandey, stable

DEPEVT_STREAM_NOSTREAM schedules dwc3_nostream_work() with a 100 ms delay.
Neither dwc3_gadget_ep_disable() nor dwc3_gadget_free_endpoints() cancel
this work before freeing struct dwc3_ep, so the handler may run after
kfree(dep) during DRD/OTG role switch teardown.

To fix it cancel the delayed work synchronously in both paths before
disable or free the endpoint.

Assisted-by: claude-mythos-preview-high
Fixes: dcfe437492e2 ("usb: dwc3: gadget: Reinitiate stream for all host NoStream behavior")
Cc: stable@vger.kernel.org
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
 drivers/usb/dwc3/gadget.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index fa0f16ffafef..ddf1e262e2aa 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1175,6 +1175,8 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep)
 					dep->name))
 		return 0;
 
+	cancel_delayed_work_sync(&dep->nostream_work);
+
 	spin_lock_irqsave(&dwc->lock, flags);
 	ret = __dwc3_gadget_ep_disable(dep);
 	spin_unlock_irqrestore(&dwc->lock, flags);
@@ -3508,6 +3510,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
 		}
 
 		dwc3_debugfs_remove_endpoint_dir(dep);
+		cancel_delayed_work_sync(&dep->nostream_work);
 		kfree(dep);
 	}
 }

base-commit: 6b8c8af514d739d0335f5579b585e02babe8a727
-- 
2.44.4


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

end of thread, other threads:[~2026-08-08 11:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 18:23 [PATCH] usb: dwc3: gadget: cancel NoStream work before endpoint teardown Radhey Shyam Pandey
2026-08-07 22:12 ` Thinh Nguyen
2026-08-08 11:07   ` Pandey, Radhey Shyam

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