Skip to content

Commit

Permalink
usb: device_next: check wLength on Set Address
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tmon-nordic committed Oct 30, 2024
1 parent c22233a commit 2cbdea8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions subsys/usb/device_next/usbd_ch9.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ static int sreq_set_address(struct usbd_context *const uds_ctx)
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
struct udc_device_caps caps = udc_caps(uds_ctx->dev);

/* Not specified if wLength is non-zero, treat as error */
if (setup->wValue > 127 || setup->wLength) {
/* Not specified if wIndex or wLength is non-zero, treat as error */
if (setup->wValue > 127 || setup->wIndex || setup->wLength) {
errno = -ENOTSUP;
return 0;
}
Expand Down

0 comments on commit 2cbdea8

Please sign in to comment.