UPSTREAM: 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.

Change-Id: Ia1535b7f8b9a1899f585e2539c3326ae6e260df6
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit b2b6d60136)
This commit is contained in:
Felipe Balbi
2019-01-11 12:58:52 +02:00
committed by Tao Huang
parent e521f4d3c3
commit 92fe32bcc4

View File

@@ -1428,6 +1428,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;