Skip to content

Commit bbf860e

Browse files
andy-shevgregkh
authored andcommitted
usb: gadget: Use correct endianness of the wLength field for WebUSB
WebUSB code uses wLength directly without proper endianness conversion. Update it to use already prepared temporary variable w_length instead. Fixes: 93c4739 ("usb: gadget: add WebUSB landing page support") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-By: Jó Ágila Bitsch <jgilab@gmail.com> Link: https://lore.kernel.org/r/20230313154522.52684-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a37eb61 commit bbf860e

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

drivers/usb/gadget/composite.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,10 +2079,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
20792079
sizeof(url_descriptor->URL)
20802080
- WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_offset);
20812081

2082-
if (ctrl->wLength < WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH
2083-
+ landing_page_length)
2084-
landing_page_length = ctrl->wLength
2085-
- WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_offset;
2082+
if (w_length < WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_length)
2083+
landing_page_length = w_length
2084+
- WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_offset;
20862085

20872086
memcpy(url_descriptor->URL,
20882087
cdev->landing_page + landing_page_offset,

0 commit comments

Comments
 (0)