diff options
author | Johan Hovold <johan@kernel.org> | 2017-01-03 10:40:02 -0500 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2017-01-04 04:43:57 -0500 |
commit | cc0909248258f679c4bb4cd315565d40abaf6bc6 (patch) | |
tree | 57faa1bd5e322b6d7f50d1ccbb1dd1671643f13e | |
parent | f09d1886a41e9063b43da493ef0e845ac8afd2fa (diff) |
USB: serial: spcp8x5: fix NULL-deref at open
Fix NULL-pointer dereference in open() should the device lack the
expected endpoints:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at spcp8x5_open+0x30/0xd0 [spcp8x5]
Fixes: 619a6f1d1423 ("USB: add usb-serial spcp8x5 driver")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r-- | drivers/usb/serial/spcp8x5.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index ef0dbf0703c5..475e6c31b266 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -154,6 +154,19 @@ static int spcp8x5_probe(struct usb_serial *serial, | |||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | static int spcp8x5_attach(struct usb_serial *serial) | ||
158 | { | ||
159 | unsigned char num_ports = serial->num_ports; | ||
160 | |||
161 | if (serial->num_bulk_in < num_ports || | ||
162 | serial->num_bulk_out < num_ports) { | ||
163 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
164 | return -ENODEV; | ||
165 | } | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | |||
157 | static int spcp8x5_port_probe(struct usb_serial_port *port) | 170 | static int spcp8x5_port_probe(struct usb_serial_port *port) |
158 | { | 171 | { |
159 | const struct usb_device_id *id = usb_get_serial_data(port->serial); | 172 | const struct usb_device_id *id = usb_get_serial_data(port->serial); |
@@ -477,6 +490,7 @@ static struct usb_serial_driver spcp8x5_device = { | |||
477 | .tiocmget = spcp8x5_tiocmget, | 490 | .tiocmget = spcp8x5_tiocmget, |
478 | .tiocmset = spcp8x5_tiocmset, | 491 | .tiocmset = spcp8x5_tiocmset, |
479 | .probe = spcp8x5_probe, | 492 | .probe = spcp8x5_probe, |
493 | .attach = spcp8x5_attach, | ||
480 | .port_probe = spcp8x5_port_probe, | 494 | .port_probe = spcp8x5_port_probe, |
481 | .port_remove = spcp8x5_port_remove, | 495 | .port_remove = spcp8x5_port_remove, |
482 | }; | 496 | }; |