usb: dwc3: gadget: properly check ep cmd
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 22 Sep 2016 09:25:28 +0000 (12:25 +0300)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:39:03 +0000 (15:39 -0500)
The cmd argument we pass to
dwc3_send_gadget_ep_cmd() could contain extra
arguments embedded. When checking for StartTransfer
command, we need to make sure to match only lower 4
bits which contain the actual command and ignore the
rest.

Reported-by: Janusz Dziedzic <januszx.dziedzic@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
(cherry picked from commit 5999914f227b20addf01297b3df24be6b4161f69)

drivers/usb/dwc3/core.h
drivers/usb/dwc3/gadget.c

index 0099ff9..205d465 100644 (file)
 #define DWC3_DEPCMD_SETTRANSFRESOURCE  (0x02 << 0)
 #define DWC3_DEPCMD_SETEPCONFIG                (0x01 << 0)
 
+#define DWC3_DEPCMD_CMD(x)             ((x) & 0xf)
+
 /* The EP number goes 0..31 so ep0 is always out and ep1 is always in */
 #define DWC3_DALEPENA_EP(n)            (1 << n)
 
index 8618e17..b072c42 100644 (file)
@@ -275,7 +275,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
                }
        }
 
-       if (cmd == DWC3_DEPCMD_STARTTRANSFER) {
+       if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
                int             needs_wakeup;
 
                needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 ||