Skip to content

Commit 425a025

Browse files
XNUBIAgregkh
authored andcommitted
usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue
commit 96bd39d upstream. dwc3_ep_dequeue() waits for completion of End Transfer command using wait_event_lock_irq(), which will release the dwc3->lock while waiting and reacquire after completion. This allows a potential race condition with ep_disable() which also removes all requests from started_list and pending_list. The check for NULL r->trb should catch this but currently it exits to the wrong 'out1' label which calls dwc3_gadget_giveback(). Since its list entry was already removed, if CONFIG_DEBUG_LIST is enabled a 'list_del corruption' bug is thrown since its next/prev pointers are already LIST_POISON1/2. If r->trb is NULL it should simply exit to 'out0'. Fixes: cf3113d ("usb: dwc3: gadget: properly increment dequeue pointer on ep_dequeue") Cc: [email protected] # v4.12+ Signed-off-by: Mayank Rana <[email protected]> Signed-off-by: Jack Pham <[email protected]> Signed-off-by: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0cc49bb commit 425a025

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
14441444
dwc->lock);
14451445

14461446
if (!r->trb)
1447-
goto out1;
1447+
goto out0;
14481448

14491449
if (r->num_pending_sgs) {
14501450
struct dwc3_trb *trb;

0 commit comments

Comments
 (0)