usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue
Hi Felipe,
Just wondering if you had a chance to look at this. This fixes a potential double-delete error which was caught when CONFIG_DEBUG_LIST=y && CONFIG_BUG_ON_DATA_CORRUPTION==y.
Quoted 27 lines · Jack Pham
From: Mayank Rana <[email protected]>
dwc3_ep_dequeue()waits for completion of End Transfer command usingwait_event_lock_irq(), which will release thedwc3->lockwhile waiting and reacquire after completion. This allows a potential race condition withep_disable()which also removes all requests fromstarted_listandpending_list. The check for NULLr->trbshould catch this but currently it exits to the wrong 'out1' label which callsdwc3_gadget_giveback(). Since its list entry was already removed, ifCONFIG_DEBUG_LISTis enabled a 'list_delcorruption' bug is thrown since its next/prev pointers are already LIST_POISON1/2. Ifr->trbis NULL it should simply exit to 'out0'.Fixes cf3113d893d4 ("usb: dwc3: gadget: properly increment dequeue pointer on ep_dequeue")Signed-off-by Mayank Rana <[email protected]>Signed-off-by Jack Pham <[email protected]>--- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/dwc3/gadget.c +0
-0
drivers/usb/dwc3/gadget.c static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, · line 1423
Quoted 8 lines
drivers/usb/dwc3/gadget.c +1
-1@@ -1417,7 +1417,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, dwc->lock);if (!r->trb) - goto out1; + goto out0;if (r->num_pending_sgs) {struct dwc3_trb *trb;
Thanks,
Jack
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html