Commit 974bba5c authored by Niklas Neronin's avatar Niklas Neronin Committed by Greg Kroah-Hartman

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.

Cc: stable@vger.kernel.org
Fixes: 3dd550a2 ("USB: usbcore: Fix slab-out-of-bounds bug during device reset")
Signed-off-by: default avatarNiklas Neronin <niklas.neronin@linux.intel.com>
Acked-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Reviewed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20231115121325.471454-1-niklas.neronin@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 791cd7af
...@@ -1047,7 +1047,7 @@ int usb_get_bos_descriptor(struct usb_device *dev) ...@@ -1047,7 +1047,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) { if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
dev_notice(ddev, "descriptor type invalid, skip\n"); dev_notice(ddev, "descriptor type invalid, skip\n");
continue; goto skip_to_next_descriptor;
} }
switch (cap_type) { switch (cap_type) {
...@@ -1078,6 +1078,7 @@ int usb_get_bos_descriptor(struct usb_device *dev) ...@@ -1078,6 +1078,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
break; break;
} }
skip_to_next_descriptor:
total_len -= length; total_len -= length;
buffer += length; buffer += length;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment