diff options
author | Johan Hovold <johan@kernel.org> | 2017-02-09 06:11:41 -0500 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2017-02-09 07:15:07 -0500 |
commit | 5182c2cf2a9bfb7f066ef0bdd2bb6330b94dd74e (patch) | |
tree | 414b05aea8dfc4e5fe15ea39804667c27cc9e8c4 | |
parent | 0e517c93dc027e49d4523fe32631606b12f0752d (diff) |
USB: serial: mos7840: fix another NULL-deref at open
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")
Cc: stable <stable@vger.kernel.org> # v2.6.19: 5c75633ef751
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r-- | drivers/usb/serial/mos7840.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index d1b92f582478..3821c53fcee9 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -1034,6 +1034,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1034 | * (can't set it up in mos7840_startup as the structures * | 1034 | * (can't set it up in mos7840_startup as the structures * |
1035 | * were not set up at that time.) */ | 1035 | * were not set up at that time.) */ |
1036 | if (port0->open_ports == 1) { | 1036 | if (port0->open_ports == 1) { |
1037 | /* FIXME: Buffer never NULL, so URB is not submitted. */ | ||
1037 | if (serial->port[0]->interrupt_in_buffer == NULL) { | 1038 | if (serial->port[0]->interrupt_in_buffer == NULL) { |
1038 | /* set up interrupt urb */ | 1039 | /* set up interrupt urb */ |
1039 | usb_fill_int_urb(serial->port[0]->interrupt_in_urb, | 1040 | usb_fill_int_urb(serial->port[0]->interrupt_in_urb, |
@@ -2116,7 +2117,8 @@ static int mos7840_calc_num_ports(struct usb_serial *serial) | |||
2116 | static int mos7840_attach(struct usb_serial *serial) | 2117 | static int mos7840_attach(struct usb_serial *serial) |
2117 | { | 2118 | { |
2118 | if (serial->num_bulk_in < serial->num_ports || | 2119 | if (serial->num_bulk_in < serial->num_ports || |
2119 | serial->num_bulk_out < serial->num_ports) { | 2120 | serial->num_bulk_out < serial->num_ports || |
2121 | serial->num_interrupt_in < 1) { | ||
2120 | dev_err(&serial->interface->dev, "missing endpoints\n"); | 2122 | dev_err(&serial->interface->dev, "missing endpoints\n"); |
2121 | return -ENODEV; | 2123 | return -ENODEV; |
2122 | } | 2124 | } |