Skip to content

Commit 75432ba

Browse files
jbrun3tgregkh
authored andcommitted
usb: gadget: f_uac2: fixup feedback endpoint stop
When the uac2 function is stopped, there seems to be an issue reported on some platforms (Intel Merrifield at least) BUG: kernel NULL pointer dereference, address: 0000000000000008 ... RIP: 0010:dwc3_gadget_del_and_unmap_request+0x19/0xe0 ... Call Trace: dwc3_remove_requests.constprop.0+0x12f/0x170 __dwc3_gadget_ep_disable+0x7a/0x160 dwc3_gadget_ep_disable+0x3d/0xd0 usb_ep_disable+0x1c/0x70 u_audio_stop_capture+0x79/0x120 [u_audio] afunc_set_alt+0x73/0x80 [usb_f_uac2] composite_setup+0x224/0x1b90 [libcomposite] The issue happens only when the gadget is using the sync type "async", not "adaptive". This indicates that problem is coming from the feedback endpoint, which is only used with async synchronization mode. The problem is that request is freed regardless of usb_ep_dequeue(), which ends up badly if the request is not actually dequeued yet. Update the feedback endpoint free function to release the endpoint the same way it is done for the data endpoint, which takes care of the problem. Fixes: 24f779d ("usb: gadget: f_uac2/u_audio: add feedback endpoint support") Reported-by: Ferry Toth <[email protected]> Tested-by: Ferry Toth <[email protected]> Acked-by: Felipe Balbi <[email protected]> Signed-off-by: Jerome Brunet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ef52b4a commit 75432ba

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/usb/gadget/function/u_audio.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ static void u_audio_iso_fback_complete(struct usb_ep *ep,
230230
int status = req->status;
231231

232232
/* i/f shutting down */
233-
if (!prm->fb_ep_enabled || req->status == -ESHUTDOWN)
233+
if (!prm->fb_ep_enabled) {
234+
kfree(req->buf);
235+
usb_ep_free_request(ep, req);
236+
return;
237+
}
238+
239+
if (req->status == -ESHUTDOWN)
234240
return;
235241

236242
/*
@@ -421,9 +427,10 @@ static inline void free_ep_fback(struct uac_rtd_params *prm, struct usb_ep *ep)
421427
prm->fb_ep_enabled = false;
422428

423429
if (prm->req_fback) {
424-
usb_ep_dequeue(ep, prm->req_fback);
425-
kfree(prm->req_fback->buf);
426-
usb_ep_free_request(ep, prm->req_fback);
430+
if (usb_ep_dequeue(ep, prm->req_fback)) {
431+
kfree(prm->req_fback->buf);
432+
usb_ep_free_request(ep, prm->req_fback);
433+
}
427434
prm->req_fback = NULL;
428435
}
429436

0 commit comments

Comments
 (0)