Skip to content

Commit 2628844

Browse files
Albert Wanggregkh
Albert Wang
authored andcommitted
usb: dwc3: gadget: Fix null pointer exception
In the endpoint interrupt functions dwc3_gadget_endpoint_transfer_in_progress() and dwc3_gadget_endpoint_trbs_complete() will dereference the endpoint descriptor. But it could be cleared in __dwc3_gadget_ep_disable() when accessory disconnected. So we need to check whether it is null or not before dereferencing it. Fixes: f09ddcf ("usb: dwc3: gadget: Prevent EP queuing while stopping transfers") Cc: stable <[email protected]> Reviewed-by: Jack Pham <[email protected]> Signed-off-by: Albert Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3b8599a commit 2628844

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,6 +3263,9 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
32633263
struct dwc3 *dwc = dep->dwc;
32643264
bool no_started_trb = true;
32653265

3266+
if (!dep->endpoint.desc)
3267+
return no_started_trb;
3268+
32663269
dwc3_gadget_ep_cleanup_completed_requests(dep, event, status);
32673270

32683271
if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
@@ -3310,6 +3313,9 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
33103313
{
33113314
int status = 0;
33123315

3316+
if (!dep->endpoint.desc)
3317+
return;
3318+
33133319
if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
33143320
dwc3_gadget_endpoint_frame_from_event(dep, event);
33153321

0 commit comments

Comments
 (0)