Skip to content

Commit 4b36c00

Browse files
Meng Dongyangrkhuangtao
authored andcommitted
UPSTREAM: usb: dwc3: gadget: properly check ep cmd
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. Change-Id: I08056bf689f8a4ea1bcec242ffab296407d41bc8 Reported-by: Janusz Dziedzic <januszx.dziedzic@intel.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com> (cherry picked from commit 5999914f227b20addf01297b3df24be6b4161f69)
1 parent 9eca1c3 commit 4b36c00

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/usb/dwc3/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@
442442
#define DWC3_DEPCMD_SETTRANSFRESOURCE (0x02 << 0)
443443
#define DWC3_DEPCMD_SETEPCONFIG (0x01 << 0)
444444

445+
#define DWC3_DEPCMD_CMD(x) ((x) & 0xf)
446+
445447
/* The EP number goes 0..31 so ep0 is always out and ep1 is always in */
446448
#define DWC3_DALEPENA_EP(n) (1 << n)
447449

drivers/usb/dwc3/gadget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
278278
}
279279
}
280280

281-
if (cmd == DWC3_DEPCMD_STARTTRANSFER) {
281+
if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
282282
int needs_wakeup;
283283

284284
needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 ||

0 commit comments

Comments
 (0)