On Mon, Feb 06, 2023 at 07:34:40PM -0500, Alan Stern wrote: > On Mon, Feb 06, 2023 at 10:52:58PM +0000, Xin Zhao wrote: > > DummyHCD assume when dummy_free_request is called, the request > > is already detached from request queues. It is correct in most > > cases. > > But when DummyHCD is detached from gadget configfs with pending > > requests and some requests are still in pending queue, > > dummy_free_request would free them directly. > > Later on, dummy_udc_stop would iterate pending queue to release > > the requests again. > > > > Stacktrace for dummy_free_reqeust > > ``` > > kfree(const void * x) (slub.c:4200) > > dummy_free_request(struct usb_ep * _ep, struct usb_request * _req) (dummy_hcd.c:691) > > usb_ep_free_request(struct usb_ep * ep, struct usb_request * req) (core.c:201) > > functionfs_unbind(struct ffs_data * ffs) (f_fs.c:1894) > > That's the bug right there. The kerneldoc for usb_ep_free_request() > says "Caller guarantees the request is not queued". So it looks like > the real solution is to fix functionfs_unbind(). This is commit ce405d561b02 ("usb: gadget: f_fs: Ensure ep0req is dequeued before free_request") IIUC. Xin, are you able to test a version with that commit?