aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/core/config.c')
-rw-r--r--drivers/usb/core/config.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 68b54bd88d1e..883549ee946c 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -960,10 +960,12 @@ int usb_get_bos_descriptor(struct usb_device *dev)
960 for (i = 0; i < num; i++) { 960 for (i = 0; i < num; i++) {
961 buffer += length; 961 buffer += length;
962 cap = (struct usb_dev_cap_header *)buffer; 962 cap = (struct usb_dev_cap_header *)buffer;
963 length = cap->bLength;
964 963
965 if (total_len < length) 964 if (total_len < sizeof(*cap) || total_len < cap->bLength) {
965 dev->bos->desc->bNumDeviceCaps = i;
966 break; 966 break;
967 }
968 length = cap->bLength;
967 total_len -= length; 969 total_len -= length;
968 970
969 if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) { 971 if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {