USB: serial: mos7840: fix another NULL-deref at open
authorJohan Hovold <johan@kernel.org>
Thu, 9 Feb 2017 11:11:41 +0000 (12:11 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Jun 2017 22:46:59 +0000 (00:46 +0200)
commit 5182c2cf2a9bfb7f066ef0bdd2bb6330b94dd74e upstream.

Fix another NULL-pointer dereference at open should a malicious device
lack an interrupt-in endpoint.

Note that the driver has a broken check for an interrupt-in endpoint
which means that an interrupt URB has never even been submitted.

Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/usb/serial/mos7840.c

index 5041b6c5b2d262cc0d8417b2563cb5280d17f4ae..3308c43d23131ec4a0ae632399a097627427c6ab 100644 (file)
@@ -1041,6 +1041,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
         * (can't set it up in mos7840_startup as the structures *
         * were not set up at that time.)                        */
        if (port0->open_ports == 1) {
+               /* FIXME: Buffer never NULL, so URB is not submitted. */
                if (serial->port[0]->interrupt_in_buffer == NULL) {
                        /* set up interrupt urb */
                        usb_fill_int_urb(serial->port[0]->interrupt_in_urb,
@@ -2258,7 +2259,8 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
 static int mos7840_attach(struct usb_serial *serial)
 {
        if (serial->num_bulk_in < serial->num_ports ||
-                       serial->num_bulk_out < serial->num_ports) {
+                       serial->num_bulk_out < serial->num_ports ||
+                       serial->num_interrupt_in < 1) {
                dev_err(&serial->interface->dev, "missing endpoints\n");
                return -ENODEV;
        }