diff mbox

[23/67] usb: dwc3: gadget: WARN() on bogus usb_ep_queue()

Message ID 1413566234-13537-24-git-send-email-balbi@ti.com
State New
Headers show

Commit Message

Felipe Balbi Oct. 17, 2014, 5:16 p.m. UTC
Some gadget/function drivers might want to do
improper request recycling by allocating a single
request from one particular endpoint and queueing
it to another completely unrelated endpoint.

One such case was found with f_loopback.c.

To prevent such cases from happening again, let's
WARN() so we get a loud enough failure and persuade
users to report errors.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/dwc3/gadget.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index d08666d..1f2a719 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1145,6 +1145,10 @@  static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
 		return -ESHUTDOWN;
 	}
 
+	if (WARN(req->dep != dep, "request %p belongs to '%s'\n",
+				request, req->dep->name))
+		return -EINVAL;
+
 	dev_vdbg(dwc->dev, "queing request %p to %s length %d\n",
 			request, ep->name, request->length);
 	trace_dwc3_ep_queue(req);