Commit 85050661 authored by Johan Hovold's avatar Johan Hovold Committed by Jiri Slaby

USB: serial: kobil_sct: fix NULL-deref in write

commit 21ce5784 upstream.

Fix NULL-pointer dereference in write() should the device lack the
expected interrupt-out endpoint:

Unable to handle kernel NULL pointer dereference at virtual address 00000054
...
PC is at kobil_write+0x144/0x2a0 [kobil_sct]

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent a42508f0
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
/* Function prototypes */ /* Function prototypes */
static int kobil_attach(struct usb_serial *serial);
static int kobil_port_probe(struct usb_serial_port *probe); static int kobil_port_probe(struct usb_serial_port *probe);
static int kobil_port_remove(struct usb_serial_port *probe); static int kobil_port_remove(struct usb_serial_port *probe);
static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
...@@ -87,6 +88,7 @@ static struct usb_serial_driver kobil_device = { ...@@ -87,6 +88,7 @@ static struct usb_serial_driver kobil_device = {
.description = "KOBIL USB smart card terminal", .description = "KOBIL USB smart card terminal",
.id_table = id_table, .id_table = id_table,
.num_ports = 1, .num_ports = 1,
.attach = kobil_attach,
.port_probe = kobil_port_probe, .port_probe = kobil_port_probe,
.port_remove = kobil_port_remove, .port_remove = kobil_port_remove,
.ioctl = kobil_ioctl, .ioctl = kobil_ioctl,
...@@ -114,6 +116,16 @@ struct kobil_private { ...@@ -114,6 +116,16 @@ struct kobil_private {
}; };
static int kobil_attach(struct usb_serial *serial)
{
if (serial->num_interrupt_out < serial->num_ports) {
dev_err(&serial->interface->dev, "missing interrupt-out endpoint\n");
return -ENODEV;
}
return 0;
}
static int kobil_port_probe(struct usb_serial_port *port) static int kobil_port_probe(struct usb_serial_port *port)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment