]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
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)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 31 Oct 2016 09:15:34 +0000 (11:15 +0200)
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>
drivers/usb/dwc3/core.h
drivers/usb/dwc3/gadget.c

index 6b60e42626a235e2f8a7197749c9e43c1b2723ea..99fa8b8b06fe79d71b87faa00e85bcef3aefc8b3 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 b3687e223e00719a3003e046933415eb693c546b..4ed8b34540f20236f01cc1d97b0afdd3a737b700 100644 (file)
@@ -258,7 +258,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 ||