--- usb.c.orig Wed Nov 21 19:59:11 2001 +++ usb.c Tue Jan 15 11:38:35 2002 @@ -2041,7 +2041,7 @@ return -ENOMEM; } - buffer = kmalloc(8, GFP_KERNEL); + buffer = kmalloc(255, GFP_KERNEL); if (!buffer) { err("unable to allocate memory for configuration descriptors"); return -ENOMEM; @@ -2049,9 +2049,9 @@ desc = (struct usb_config_descriptor *)buffer; for (cfgno = 0; cfgno < dev->descriptor.bNumConfigurations; cfgno++) { - /* We grab the first 8 bytes so we know how long the whole */ + /* We grab the first 255 bytes so we know how long the whole */ /* configuration is */ - result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 8); + result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 255); if (result < 8) { if (result < 0) err("unable to get descriptor"); @@ -2072,19 +2072,24 @@ goto err; } - /* Now that we know the length, get the whole thing */ - result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bigbuffer, length); - if (result < 0) { - err("couldn't get all of config descriptors"); - kfree(bigbuffer); - goto err; - } + if (length > 255) { + /* Now that we know the length, get the whole thing */ + result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bigbuffer, length); + if (result < 0) { + err("couldn't get all of config descriptors"); + kfree(bigbuffer); + goto err; + } - if (result < length) { - err("config descriptor too short (expected %i, got %i)", length, result); - result = -EINVAL; - kfree(bigbuffer); - goto err; + if (result < length) { + err("config descriptor too short (expected %i, got %i)", length, result); + result = -EINVAL; + kfree(bigbuffer); + goto err; + } + } + else { + memcpy(bigbuffer, buffer, length); } dev->rawdescriptors[cfgno] = bigbuffer;