Skip to content

Commit 1ae570a

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: mos7840: fix another NULL-deref at open
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: 3f54297 ("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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 04fae8a commit 1ae570a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/usb/serial/mos7840.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
10241024
* (can't set it up in mos7840_startup as the structures *
10251025
* were not set up at that time.) */
10261026
if (port0->open_ports == 1) {
1027+
/* FIXME: Buffer never NULL, so URB is not submitted. */
10271028
if (serial->port[0]->interrupt_in_buffer == NULL) {
10281029
/* set up interrupt urb */
10291030
usb_fill_int_urb(serial->port[0]->interrupt_in_urb,
@@ -2119,7 +2120,8 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
21192120
static int mos7840_attach(struct usb_serial *serial)
21202121
{
21212122
if (serial->num_bulk_in < serial->num_ports ||
2122-
serial->num_bulk_out < serial->num_ports) {
2123+
serial->num_bulk_out < serial->num_ports ||
2124+
serial->num_interrupt_in < 1) {
21232125
dev_err(&serial->interface->dev, "missing endpoints\n");
21242126
return -ENODEV;
21252127
}

0 commit comments

Comments
 (0)