usb: gadget: composite: avoid access beyond array max length

One of the USB CV MSC tests issues Get Max LUN request with
invalid wIndex (wIndex = 65535) parameter.

Add proper handling to prevent array index out of bounds issue.

Signed-off-by: Maulik Mankad <maulik@ti.com>
Cc: David Brownell <david-b@pacbell.net>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by Maulik Mankad and committed by Greg Kroah-Hartman 3c47eb06 d14fc1a7

+3 -2
+3 -2
drivers/usb/gadget/composite.c
··· 928 */ 929 switch (ctrl->bRequestType & USB_RECIP_MASK) { 930 case USB_RECIP_INTERFACE: 931 - if (cdev->config) 932 - f = cdev->config->interface[intf]; 933 break; 934 935 case USB_RECIP_ENDPOINT:
··· 928 */ 929 switch (ctrl->bRequestType & USB_RECIP_MASK) { 930 case USB_RECIP_INTERFACE: 931 + if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES) 932 + break; 933 + f = cdev->config->interface[intf]; 934 break; 935 936 case USB_RECIP_ENDPOINT: