summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFei Yang <fei.yang@intel.com>2016-04-20 06:08:43 (GMT)
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-04-28 06:01:34 (GMT)
commitae411413760785a0a2ce6cb44d5afe95115aa24d (patch)
tree8ee76804466800a5612d64377cd2d747121afd9a
parent818ec3aba883f58225c9f5a2318cf373263869ed (diff)
downloadlinux-ae411413760785a0a2ce6cb44d5afe95115aa24d.tar.xz
usb: dwc3: ep0: sanity check test mode selector
In case host sends us an unsupported test mode, we *must* stall this request. This will tell the host that the selector is invalid and we won't put the controller in unsupported test modes which could have undetermined side-effects. Signed-off-by: Fei Yang <fei.yang@intel.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
-rw-r--r--drivers/usb/dwc3/ep0.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 143deb4..51b52a7 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -463,8 +463,18 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
if (!set)
return -EINVAL;
- dwc->test_mode_nr = wIndex >> 8;
- dwc->test_mode = true;
+ switch (wIndex >> 8) {
+ case TEST_J:
+ case TEST_K:
+ case TEST_SE0_NAK:
+ case TEST_PACKET:
+ case TEST_FORCE_EN:
+ dwc->test_mode_nr = wIndex >> 8;
+ dwc->test_mode = true;
+ break;
+ default:
+ return -EINVAL;
+ }
break;
default:
return -EINVAL;