aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Wu <cooloney@kernel.org>2009-01-07 11:21:19 -0500
committerGreg Kroah-Hartman <gregkh@kvm.kroah.org>2009-01-27 19:15:35 -0500
commit08889517b3713926169d79d99782192e86acdc67 (patch)
tree8d5a6641ef9e96fa100d08bf67603989cf90e00c
parentdd4dff8b035f6dda69ece98e20d4c2d76b9f97d1 (diff)
USB: composite: 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. Signed-off-by: Bryan Wu <cooloney@kernel.org> Acked-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/composite.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 363951eb333c..5d11c291f1ad 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -683,6 +683,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
683 struct usb_request *req = cdev->req; 683 struct usb_request *req = cdev->req;
684 int value = -EOPNOTSUPP; 684 int value = -EOPNOTSUPP;
685 u16 w_index = le16_to_cpu(ctrl->wIndex); 685 u16 w_index = le16_to_cpu(ctrl->wIndex);
686 u8 intf = w_index & 0xFF;
686 u16 w_value = le16_to_cpu(ctrl->wValue); 687 u16 w_value = le16_to_cpu(ctrl->wValue);
687 u16 w_length = le16_to_cpu(ctrl->wLength); 688 u16 w_length = le16_to_cpu(ctrl->wLength);
688 struct usb_function *f = NULL; 689 struct usb_function *f = NULL;
@@ -769,7 +770,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
769 goto unknown; 770 goto unknown;
770 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES) 771 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
771 break; 772 break;
772 f = cdev->config->interface[w_index]; 773 f = cdev->config->interface[intf];
773 if (!f) 774 if (!f)
774 break; 775 break;
775 if (w_value && !f->set_alt) 776 if (w_value && !f->set_alt)
@@ -781,7 +782,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
781 goto unknown; 782 goto unknown;
782 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES) 783 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
783 break; 784 break;
784 f = cdev->config->interface[w_index]; 785 f = cdev->config->interface[intf];
785 if (!f) 786 if (!f)
786 break; 787 break;
787 /* lots of interfaces only need altsetting zero... */ 788 /* lots of interfaces only need altsetting zero... */
@@ -808,7 +809,7 @@ unknown:
808 */ 809 */
809 if ((ctrl->bRequestType & USB_RECIP_MASK) 810 if ((ctrl->bRequestType & USB_RECIP_MASK)
810 == USB_RECIP_INTERFACE) { 811 == USB_RECIP_INTERFACE) {
811 f = cdev->config->interface[w_index]; 812 f = cdev->config->interface[intf];
812 if (f && f->setup) 813 if (f && f->setup)
813 value = f->setup(f, ctrl); 814 value = f->setup(f, ctrl);
814 else 815 else