Commit 520fe763 authored by Felipe Balbi's avatar Felipe Balbi

usb: dwc3: ep0: fix for dead code

commit 6856d30c (usb: dwc3: ep0: return early
on NULL requests) tried to fix a minor corner
case where we could dereference a NULL pointer
but it also ended up introducing some dead code.

Unfortunately, that dead code, if reached, could
end up starving the endpoint request list because
a request would never be given back when it should.

Fix this by moving the check for empty request list
before its first use.
Reported-by: default avatarDave Jones <davej@redhat.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 206c5f60
...@@ -791,6 +791,10 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, ...@@ -791,6 +791,10 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
trb = dwc->ep0_trb; trb = dwc->ep0_trb;
r = next_request(&ep0->request_list);
if (!r)
return;
status = DWC3_TRB_SIZE_TRBSTS(trb->size); status = DWC3_TRB_SIZE_TRBSTS(trb->size);
if (status == DWC3_TRBSTS_SETUP_PENDING) { if (status == DWC3_TRBSTS_SETUP_PENDING) {
dwc3_trace(trace_dwc3_ep0, "Setup Pending received"); dwc3_trace(trace_dwc3_ep0, "Setup Pending received");
...@@ -801,10 +805,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, ...@@ -801,10 +805,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
return; return;
} }
r = next_request(&ep0->request_list);
if (!r)
return;
ur = &r->request; ur = &r->request;
length = trb->size & DWC3_TRB_SIZE_MASK; length = trb->size & DWC3_TRB_SIZE_MASK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment