mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-12 15:49:17 -04:00
usb: gadget: audio: Free requests only after callback
As per the kernel doc for usb_ep_dequeue(), it states that "this routine is asynchronous, that is, it may return before the completion routine runs". And indeed the dwc3 gadget driver recently updated its behavior to place dequeued requests on to a cancelled list to be given back later after the endpoint is stopped. The free_ep() was incorrectly assuming that a request was ready to be freed after calling dequeue which results in a use-after-free in dwc3 when it traverses its cancelled list. Fix this by moving the usb_ep_free_request() call to the callback itself in case the ep is disabled. Change-Id: I51751e002ad86b226d9f0d872c66a77e94e8cab7 Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
parent
da731b304a
commit
29974620bd
1 changed files with 6 additions and 2 deletions
|
|
@ -89,7 +89,12 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
|
|||
struct snd_uac_chip *uac = prm->uac;
|
||||
|
||||
/* i/f shutting down */
|
||||
if (!prm->ep_enabled || req->status == -ESHUTDOWN)
|
||||
if (!prm->ep_enabled) {
|
||||
usb_ep_free_request(ep, req);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->status == -ESHUTDOWN)
|
||||
return;
|
||||
|
||||
/*
|
||||
|
|
@ -352,7 +357,6 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep)
|
|||
for (i = 0; i < params->req_number; i++) {
|
||||
if (prm->ureq[i].req) {
|
||||
usb_ep_dequeue(ep, prm->ureq[i].req);
|
||||
usb_ep_free_request(ep, prm->ureq[i].req);
|
||||
prm->ureq[i].req = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue