summaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3
diff options
context:
space:
mode:
authorFelipe Balbi2019-01-11 11:58:52 +0100
committerFelipe Balbi2019-01-28 11:53:15 +0100
commitb2b6d601365a1acb90b87c85197d797447bc9a2c (patch)
tree117464870eb93c0e828effb33c1fec511d3ddca7 /drivers/usb/dwc3
parentusb: dwc3: gadget: add dwc3_request status tracking (diff)
downloadkernel-qcow2-linux-b2b6d601365a1acb90b87c85197d797447bc9a2c.tar.gz
kernel-qcow2-linux-b2b6d601365a1acb90b87c85197d797447bc9a2c.tar.xz
kernel-qcow2-linux-b2b6d601365a1acb90b87c85197d797447bc9a2c.zip
usb: dwc3: gadget: prevent dwc3_request from being queued twice
Queueing the same request twice can introduce hard-to-debug problems. At least one function driver - Android's f_mtp.c - is known to cause this problem. While that function is out-of-tree, this is a problem that's easy enough to avoid. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r--drivers/usb/dwc3/gadget.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 9fde48656044..064d5161c483 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1437,6 +1437,11 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
&req->request, req->dep->name))
return -EINVAL;
+ if (WARN(req->status < DWC3_REQUEST_STATUS_COMPLETED,
+ "%s: request %pK already in flight\n",
+ dep->name, &req->request))
+ return -EINVAL;
+
pm_runtime_get(dwc->dev);
req->request.actual = 0;