aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3
diff options
context:
space:
mode:
authorFelipe Balbi <felipe.balbi@linux.intel.com>2019-01-21 06:01:16 -0500
committerFelipe Balbi <felipe.balbi@linux.intel.com>2019-02-04 01:46:01 -0500
commit9f45581f5eec6786c6eded2b3c85345d82a910c9 (patch)
tree1165aec166fec9bf1e6926a78a2b0dedfcb6e2d5 /drivers/usb/dwc3
parent974a1368c33ebb09c94c9ec1b523908cc7ca068f (diff)
usb: dwc3: gadget: early giveback if End Transfer already completed
There is a rare race condition that may happen during a Disconnect Interrupt if we have a started request that happens to be dequeued *after* completion of End Transfer command. If that happens, that request will be left waiting for completion of an End Transfer command that will never happen. If End Transfer command has already completed before, we are safe to giveback the request straight away. Tested-by: Thinh Nguyen <thinhn@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r--drivers/usb/dwc3/gadget.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index eaeea8ff5191..b82a8885747d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1550,7 +1550,10 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
1550 goto out0; 1550 goto out0;
1551 1551
1552 dwc3_gadget_move_cancelled_request(req); 1552 dwc3_gadget_move_cancelled_request(req);
1553 goto out0; 1553 if (dep->flags & DWC3_EP_TRANSFER_STARTED)
1554 goto out0;
1555 else
1556 goto out1;
1554 } 1557 }
1555 dev_err(dwc->dev, "request %pK was not queued to %s\n", 1558 dev_err(dwc->dev, "request %pK was not queued to %s\n",
1556 request, ep->name); 1559 request, ep->name);
@@ -1558,6 +1561,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
1558 goto out0; 1561 goto out0;
1559 } 1562 }
1560 1563
1564out1:
1561 dwc3_gadget_giveback(dep, req, -ECONNRESET); 1565 dwc3_gadget_giveback(dep, req, -ECONNRESET);
1562 1566
1563out0: 1567out0: