Title: [5872] trunk/drivers/usb/gadget/composite.c: Fix bug: low byte of w_index is the usb interface number not the whole 2 bytes of w_index
- Revision
- 5872
- Author
- cooloney
- Date
- 2008-12-17 21:24:49 -0600 (Wed, 17 Dec 2008)
Log Message
Fix bug: low byte of w_index is the usb interface number not the whole 2 bytes of w_index
In some usb gadget driver, for example usb audio class device, the high byte of w_index
is the entity id and low byte is the interface number. If we use the 2 bytes of w_index
as the array number, we will get a wrong pointer or NULL pointer.
This patch fixes this issue.
Modified Paths
Diff
Modified: trunk/drivers/usb/gadget/composite.c (5871 => 5872)
--- trunk/drivers/usb/gadget/composite.c 2008-12-18 03:19:44 UTC (rev 5871)
+++ trunk/drivers/usb/gadget/composite.c 2008-12-18 03:24:49 UTC (rev 5872)
@@ -683,6 +683,7 @@
struct usb_request *req = cdev->req;
int value = -EOPNOTSUPP;
u16 w_index = le16_to_cpu(ctrl->wIndex);
+ u8 intf = w_index & 0xFF;
u16 w_value = le16_to_cpu(ctrl->wValue);
u16 w_length = le16_to_cpu(ctrl->wLength);
struct usb_function *f = NULL;
@@ -769,7 +770,7 @@
goto unknown;
if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
break;
- f = cdev->config->interface[w_index];
+ f = cdev->config->interface[intf];
if (!f)
break;
if (w_value && !f->set_alt)
@@ -781,7 +782,7 @@
goto unknown;
if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
break;
- f = cdev->config->interface[w_index];
+ f = cdev->config->interface[intf];
if (!f)
break;
/* lots of interfaces only need altsetting zero... */
@@ -808,7 +809,7 @@
*/
if ((ctrl->bRequestType & USB_RECIP_MASK)
== USB_RECIP_INTERFACE) {
- f = cdev->config->interface[w_index];
+ f = cdev->config->interface[intf];
if (f && f->setup)
value = f->setup(f, ctrl);
else
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
http://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits