USB: serial: oti6858: fix NULL-deref at open
[pandora-kernel.git] / drivers / usb / serial / oti6858.c
index 8ceaa89..dffbe61 100644 (file)
@@ -347,9 +347,17 @@ static void send_data(struct work_struct *work)
 static int oti6858_startup(struct usb_serial *serial)
 {
        struct usb_serial_port *port = serial->port[0];
+       unsigned char num_ports = serial->num_ports;
        struct oti6858_private *priv;
        int i;
 
+       if (serial->num_bulk_in < num_ports ||
+                       serial->num_bulk_out < num_ports ||
+                       serial->num_interrupt_in < num_ports) {
+               dev_err(&serial->interface->dev, "missing endpoints\n");
+               return -ENODEV;
+       }
+
        for (i = 0; i < serial->num_ports; ++i) {
                priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL);
                if (!priv)