diff options
author | Johan Hovold <johan@kernel.org> | 2017-01-03 10:40:00 -0500 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2017-01-04 04:43:56 -0500 |
commit | 76ab439ed1b68778e9059c79ecc5d14de76c89a8 (patch) | |
tree | 6ef06a8b28a032bcba36504d840450e1d5cc9e6a /drivers/usb | |
parent | 5afeef2366db14587b65558bbfd5a067542e07fb (diff) |
USB: serial: pl2303: fix NULL-deref at open
Fix NULL-pointer dereference in open() should a type-0 or type-1 device
lack the expected endpoints:
Unable to handle kernel NULL pointer dereference at virtual address 00000030
...
PC is at pl2303_open+0x38/0xec [pl2303]
Note that a missing interrupt-in endpoint would have caused open() to
fail.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/pl2303.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index ae682e4eeaef..46fca6b75846 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -220,9 +220,17 @@ static int pl2303_probe(struct usb_serial *serial, | |||
220 | static int pl2303_startup(struct usb_serial *serial) | 220 | static int pl2303_startup(struct usb_serial *serial) |
221 | { | 221 | { |
222 | struct pl2303_serial_private *spriv; | 222 | struct pl2303_serial_private *spriv; |
223 | unsigned char num_ports = serial->num_ports; | ||
223 | enum pl2303_type type = TYPE_01; | 224 | enum pl2303_type type = TYPE_01; |
224 | unsigned char *buf; | 225 | unsigned char *buf; |
225 | 226 | ||
227 | if (serial->num_bulk_in < num_ports || | ||
228 | serial->num_bulk_out < num_ports || | ||
229 | serial->num_interrupt_in < num_ports) { | ||
230 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
231 | return -ENODEV; | ||
232 | } | ||
233 | |||
226 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); | 234 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); |
227 | if (!spriv) | 235 | if (!spriv) |
228 | return -ENOMEM; | 236 | return -ENOMEM; |