Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,7 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
/* descriptor may appear anywhere in config */
if (__usb_get_extra_descriptor (udev->rawdescriptors[0],
le16_to_cpu(udev->config[0].desc.wTotalLength),
USB_DT_OTG, (void **) &desc) == 0) {
USB_DT_OTG, (void **) &desc, sizeof(*desc));
if (desc->bmAttributes & USB_OTG_HNP) {
unsigned port1 = udev->portnum;

Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/core/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,14 +710,14 @@ EXPORT_SYMBOL(usb_get_xfer_ring_dma_addr);
*/

int __usb_get_extra_descriptor(char *buffer, unsigned size,
unsigned char type, void **ptr)
unsigned char type, void **ptr, size_t minsize)
{
struct usb_descriptor_header *header;

while (size >= sizeof(struct usb_descriptor_header)) {
header = (struct usb_descriptor_header *)buffer;

if (header->bLength < 2) {
if (header->bLength < 2 || header->bLength > size) {
printk(KERN_ERR
"%s: bogus descriptor, type %d length %d\n",
usbcore_name,
Expand All @@ -726,7 +726,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
return -1;
}

if (header->bDescriptorType == type) {
if (header->bDescriptorType == type && header->bLength >= minsize) {
*ptr = header;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/hwa-hc.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ static int hwahc_security_create(struct hwahc *hwahc)
top = itr + itr_size;
result = __usb_get_extra_descriptor(usb_dev->rawdescriptors[index],
le16_to_cpu(usb_dev->actconfig->desc.wTotalLength),
USB_DT_SECURITY, (void **) &secd);
USB_DT_SECURITY, (void **) &secd, sizeof(*secd));
if (result == -1) {
dev_warn(dev, "BUG? WUSB host has no security descriptors\n");
return 0;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ struct usb_host_bos {
};

int __usb_get_extra_descriptor(char *buffer, unsigned size,
unsigned char type, void **ptr);
unsigned char type, void **ptr, size_t min);
#define usb_get_extra_descriptor(ifpoint, type, ptr) \
__usb_get_extra_descriptor((ifpoint)->extra, \
(ifpoint)->extralen, \
Expand Down