From: Fei Yang <[email protected]>

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 <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
---
 drivers/usb/dwc3/ep0.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index c78238dc76fc..660a997ce023 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;
-- 
2.8.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to