UPSTREAM: usb: dwc2: gadget: Check for ep0 in enable
authorVahram Aharonyan <vahrama@synopsys.com>
Thu, 28 Apr 2016 03:20:46 +0000 (20:20 -0700)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 10:48:32 +0000 (18:48 +0800)
Replaced the WARN_ON with a check and return of -EINVAL in the
dwc2_hsotg_ep_enable function if ep0 is passed in.

Change-Id: Idf4bf147a52ff9dca294f76263438e41cc511cfc
Signed-off-by: Vahram Aharonyan <vahrama@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 8c3d609275f7f39d308e5c40a6220c67454f7a28)

drivers/usb/dwc2/gadget.c

index 818f158232bb6eb84e13e16a85808a25b7b1f668..d330190f58ef81451452a5c1a2cf96b9f52490eb 100644 (file)
@@ -2631,7 +2631,10 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
                desc->wMaxPacketSize, desc->bInterval);
 
        /* not to be called for EP0 */
-       WARN_ON(index == 0);
+       if (index == 0) {
+               dev_err(hsotg->dev, "%s: called for EP 0\n", __func__);
+               return -EINVAL;
+       }
 
        dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0;
        if (dir_in != hs_ep->dir_in) {