Skip to content

Commit 0755f3f

Browse files
Albert Wanggregkh
Albert Wang
authored andcommitted
usb: dwc3: gadget: Fix null pointer exception
commit 2628844 upstream. 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 140e2df commit 0755f3f

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
@@ -2918,6 +2918,9 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
29182918
struct dwc3 *dwc = dep->dwc;
29192919
bool no_started_trb = true;
29202920

2921+
if (!dep->endpoint.desc)
2922+
return no_started_trb;
2923+
29212924
dwc3_gadget_ep_cleanup_completed_requests(dep, event, status);
29222925

29232926
if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
@@ -2965,6 +2968,9 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
29652968
{
29662969
int status = 0;
29672970

2971+
if (!dep->endpoint.desc)
2972+
return;
2973+
29682974
if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
29692975
dwc3_gadget_endpoint_frame_from_event(dep, event);
29702976

0 commit comments

Comments
 (0)