usb: gadget: composite: don't try standard handling for non-standard requests
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Tue, 3 Mar 2015 09:52:04 +0000 (10:52 +0100)
committerFelipe Balbi <balbi@ti.com>
Tue, 10 Mar 2015 20:33:33 +0000 (15:33 -0500)
If a non-standard request is processed and its parameters just happen
to match those of some standard request, the logic of composite_setup()
can be fooled, so don't even try any switch cases, just go to the
proper place where unknown requests are handled.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/composite.c

index 13adfd1a3f54947f860f10161156a057dde274bc..9fb92310fb2be85416088e23207770b18e196014 100644 (file)
@@ -1472,6 +1472,13 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
        req->length = 0;
        gadget->ep0->driver_data = cdev;
 
+       /*
+        * Don't let non-standard requests match any of the cases below
+        * by accident.
+        */
+       if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD)
+               goto unknown;
+
        switch (ctrl->bRequest) {
 
        /* we handle all standard USB descriptors */