summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorNiklas Neronin <niklas.neronin@linux.intel.com>2023-11-15 14:13:25 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-03 07:33:09 +0100
commit7c0244cc311a4038505b73682b7c8ceaa5c7a8c8 (patch)
tree527cf7f82ab8130e194404fbb59663366f482533 /drivers/usb
parent9c6ad38d4e0d1a03b64903db03149905997b1c75 (diff)
downloadlinux-stable-7c0244cc311a4038505b73682b7c8ceaa5c7a8c8.tar.gz
linux-stable-7c0244cc311a4038505b73682b7c8ceaa5c7a8c8.tar.bz2
linux-stable-7c0244cc311a4038505b73682b7c8ceaa5c7a8c8.zip
usb: config: fix iteration issue in 'usb_get_bos_descriptor()'
commit 974bba5c118f4c2baf00de0356e3e4f7928b4cbc upstream. 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: 3dd550a2d365 ("USB: usbcore: Fix slab-out-of-bounds bug during device reset") Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com> Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/r/20231115121325.471454-1-niklas.neronin@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/config.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index b19e38d5fd10..7f8d33f92ddb 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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;
}