]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: usbtest: fix NULL pointer dereference
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 29 Sep 2017 14:54:24 +0000 (10:54 -0400)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Wed, 11 Oct 2017 10:15:11 +0000 (13:15 +0300)
If the usbtest driver encounters a device with an IN bulk endpoint but
no OUT bulk endpoint, it will try to dereference a NULL pointer
(out->desc.bEndpointAddress).  The problem can be solved by adding a
missing test.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/misc/usbtest.c

index 113e38bfe0ef9a8b2e265c4f721036b93c020cf6..b3fc602b2e247ea150a49c13323ae66cde2b6b4b 100644 (file)
@@ -202,12 +202,13 @@ get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf)
                        return tmp;
        }
 
-       if (in) {
+       if (in)
                dev->in_pipe = usb_rcvbulkpipe(udev,
                        in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+       if (out)
                dev->out_pipe = usb_sndbulkpipe(udev,
                        out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
-       }
+
        if (iso_in) {
                dev->iso_in = &iso_in->desc;
                dev->in_iso_pipe = usb_rcvisocpipe(udev,