UPSTREAM: 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: 24f779dac8f3 ("usb: gadget: f_uac2/u_audio: add feedback endpoint support") Reported-by: Ferry Toth <ftoth@exalondelft.nl> Tested-by: Ferry Toth <ftoth@exalondelft.nl> Acked-by: Felipe Balbi <balbi@kernel.org> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Link: https://lore.kernel.org/r/20210827075853.266912-1-jbrunet@baylibre.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Bug: 199044440 Change-Id: I96cc41a0dc0e3ad15f9c9bbe5737f22e0fc74433 (cherry picked from commit 75432ba583a8a374b8d1ad2d3ba559a78f7454fc) Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
406a51b486
commit
3d371f087c
@@ -230,7 +230,13 @@ static void u_audio_iso_fback_complete(struct usb_ep *ep,
|
||||
int status = req->status;
|
||||
|
||||
/* i/f shutting down */
|
||||
if (!prm->fb_ep_enabled || req->status == -ESHUTDOWN)
|
||||
if (!prm->fb_ep_enabled) {
|
||||
kfree(req->buf);
|
||||
usb_ep_free_request(ep, req);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->status == -ESHUTDOWN)
|
||||
return;
|
||||
|
||||
/*
|
||||
@@ -421,9 +427,10 @@ static inline void free_ep_fback(struct uac_rtd_params *prm, struct usb_ep *ep)
|
||||
prm->fb_ep_enabled = false;
|
||||
|
||||
if (prm->req_fback) {
|
||||
usb_ep_dequeue(ep, prm->req_fback);
|
||||
if (usb_ep_dequeue(ep, prm->req_fback)) {
|
||||
kfree(prm->req_fback->buf);
|
||||
usb_ep_free_request(ep, prm->req_fback);
|
||||
}
|
||||
prm->req_fback = NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user