Skip to content

Commit f90f5af

Browse files
Thinh Nguyengregkh
authored andcommitted
usb: dwc3: gadget: Clear ep descriptor last
Until the endpoint is disabled, its descriptors should remain valid. When its requests are removed from ep disable, the request completion routine may attempt to access the endpoint's descriptor. Don't clear the descriptors before that. Fixes: f09ddcf ("usb: dwc3: gadget: Prevent EP queuing while stopping transfers") Cc: stable@vger.kernel.org Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Link: https://lore.kernel.org/r/45db7c83b209259115bf652af210f8b2b3b1a383.1668561364.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e0481e5 commit f90f5af

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,12 +1024,6 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
10241024
reg &= ~DWC3_DALEPENA_EP(dep->number);
10251025
dwc3_writel(dwc->regs, DWC3_DALEPENA, reg);
10261026

1027-
/* Clear out the ep descriptors for non-ep0 */
1028-
if (dep->number > 1) {
1029-
dep->endpoint.comp_desc = NULL;
1030-
dep->endpoint.desc = NULL;
1031-
}
1032-
10331027
dwc3_remove_requests(dwc, dep, -ESHUTDOWN);
10341028

10351029
dep->stream_capable = false;
@@ -1044,6 +1038,12 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
10441038
mask |= (DWC3_EP_DELAY_STOP | DWC3_EP_TRANSFER_STARTED);
10451039
dep->flags &= mask;
10461040

1041+
/* Clear out the ep descriptors for non-ep0 */
1042+
if (dep->number > 1) {
1043+
dep->endpoint.comp_desc = NULL;
1044+
dep->endpoint.desc = NULL;
1045+
}
1046+
10471047
return 0;
10481048
}
10491049

0 commit comments

Comments
 (0)