Skip to content

Commit f89fef7

Browse files
Epicuriusgregkh
authored andcommitted
usb: config: fix iteration issue in 'usb_get_bos_descriptor()'
[ Upstream commit 974bba5 ] The BOS descriptor defines a root descriptor and is the base descriptor for accessing a family of related descriptors. Function 'usb_get_bos_descriptor()' encounters an iteration issue when skipping the 'USB_DT_DEVICE_CAPABILITY' descriptor type. This results in the same descriptor being read repeatedly. To address this issue, a 'goto' statement is introduced to ensure that the pointer and the amount read is updated correctly. This ensures that the function iterates to the next descriptor instead of reading the same descriptor repeatedly. Cc: [email protected] Fixes: 3dd550a ("USB: usbcore: Fix slab-out-of-bounds bug during device reset") Signed-off-by: Niklas Neronin <[email protected]> Acked-by: Mathias Nyman <[email protected]> Reviewed-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 9aff7c5 commit f89fef7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/usb/core/config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
10471047

10481048
if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
10491049
dev_notice(ddev, "descriptor type invalid, skip\n");
1050-
continue;
1050+
goto skip_to_next_descriptor;
10511051
}
10521052

10531053
switch (cap_type) {
@@ -1081,6 +1081,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
10811081
break;
10821082
}
10831083

1084+
skip_to_next_descriptor:
10841085
total_len -= length;
10851086
buffer += length;
10861087
}

0 commit comments

Comments
 (0)