Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae411413 authored by Fei Yang's avatar Fei Yang Committed by Felipe Balbi
Browse files

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: default avatarFei Yang <fei.yang@intel.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 818ec3ab
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -463,6 +463,12 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
			if (!set)
				return -EINVAL;

			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;
@@ -470,6 +476,10 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
				return -EINVAL;
			}
			break;
		default:
			return -EINVAL;
		}
		break;

	case USB_RECIP_INTERFACE:
		switch (wValue) {