usb: config: fix iteration issue in 'usb_get_bos_descriptor()'
Subsystems (2)
PATCH 1/1 usb: config: fix iteration issue in 'usb_get_bos_descriptor()'
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.
--- drivers/usb/core/config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/core/config.c +2 -1
@@ -1047,7 +1047,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)if (cap->bDescriptorType !=USB_DT_DEVICE_CAPABILITY ) {dev_notice (ddev,"descriptor type invalid, skip\n" ); -continue ; + goto skip_to_next_descriptor; }switch (cap_type) {
@@ -1078,6 +1078,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)break ; } +skip_to_next_descriptor: total_len -= length; buffer += length; }
Signature · 1 line
2.42.0
Quoted 12 lines · Niklas Neronin
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.
Quoted 4 lines
Fixes 3dd550a2d365 ("USB: usbcore: Fix slab-out-of-bounds bug during device reset")Signed-off-by Niklas Neronin <[email protected]>---
Quoted 12 lines · Niklas Neronin
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.
Quoted 4 lines
Fixes 3dd550a2d365 ("USB: usbcore: Fix slab-out-of-bounds bug during device reset")Signed-off-by Niklas Neronin <[email protected]>---
Don't know how I missed that four years ago...
Quoted 27 lines
drivers/usb/core/config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/core/config.c +2
-1@@ -1047,7 +1047,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)if (cap->bDescriptorType !=USB_DT_DEVICE_CAPABILITY ) {dev_notice (ddev,"descriptor type invalid, skip\n" ); -continue ; + goto skip_to_next_descriptor; }switch (cap_type) {@@ -1078,6 +1078,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)break ; } +skip_to_next_descriptor: total_len -= length; buffer += length; }Signature · 1 line
2.42.0