patch-2.3.27 linux/drivers/usb/usb.c

Next file: linux/drivers/usb/usb_scsi.c
Previous file: linux/drivers/usb/usb-serial.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.26/linux/drivers/usb/usb.c linux/drivers/usb/usb.c
@@ -720,7 +720,7 @@
 	}
 
 	memset(config->interface, 0,
-	       config->bNumInterfaces*sizeof(struct usb_interface_descriptor));
+	       config->bNumInterfaces * sizeof(struct usb_interface));
 
 	buffer += config->bLength;
 	size -= config->bLength;
@@ -1140,13 +1140,16 @@
 	}
 
 	if (usb_get_string(dev, dev->string_langid, index, u.buffer, 4) < 0 ||
-	    usb_get_string(dev, dev->string_langid, index, u.buffer,
-			      u.desc.bLength) < 0) {
+	    ((ret = usb_get_string(dev, dev->string_langid, index, u.buffer,
+			      u.desc.bLength)) < 0)) {
 		printk(KERN_ERR "usb: error retrieving string\n");
 		return NULL;
 	}
 
+	if (ret > 0) ret /= 2;		/* going from 16-bit chars to 8-bit */
 	len = u.desc.bLength / 2;	/* includes terminating null */
+					/* after removing bLength & bDescType */
+	if (ret < len) len = ret;	/* use min of (ret, len) */
 
 	ptr = kmalloc(len, GFP_KERNEL);
 	if (!ptr) {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)