Skip to content

Commit 3881b06

Browse files
committed
usb: device_next: check wIndex on Set Address
Set Address behavior is not specified when wValue is greater than 127, or if wIndex or wLength are non-zero. USB stack did check wValue and wLength but didn't care about wIndex value. Extend the check so non-zero wIndex also results in STALL response. Signed-off-by: Tomasz Moń <[email protected]>
1 parent c22233a commit 3881b06

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/usb/device_next/usbd_ch9.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ static int sreq_set_address(struct usbd_context *const uds_ctx)
8686
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
8787
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
8888

89-
/* Not specified if wLength is non-zero, treat as error */
90-
if (setup->wValue > 127 || setup->wLength) {
89+
/* Not specified if wIndex or wLength is non-zero, treat as error */
90+
if (setup->wValue > 127 || setup->wIndex || setup->wLength) {
9191
errno = -ENOTSUP;
9292
return 0;
9393
}

0 commit comments

Comments
 (0)