usb: xhci: Fix panic if disconnect
[pandora-kernel.git] / drivers / usb / serial / digi_acceleport.c
index e92cbef..e59bd95 100644 (file)
@@ -1489,12 +1489,30 @@ static int digi_startup_device(struct usb_serial *serial)
 static int digi_startup(struct usb_serial *serial)
 {
 
+       struct device *dev = &serial->interface->dev;
        int i;
        struct digi_port *priv;
        struct digi_serial *serial_priv;
 
        dbg("digi_startup: TOP");
 
+       /* check whether the device has the expected number of endpoints */
+       if (serial->num_port_pointers < serial->type->num_ports + 1) {
+               dev_err(dev, "OOB endpoints missing\n");
+               return -ENODEV;
+       }
+
+       for (i = 0; i < serial->type->num_ports + 1 ; i++) {
+               if (!serial->port[i]->read_urb) {
+                       dev_err(dev, "bulk-in endpoint missing\n");
+                       return -ENODEV;
+               }
+               if (!serial->port[i]->write_urb) {
+                       dev_err(dev, "bulk-out endpoint missing\n");
+                       return -ENODEV;
+               }
+       }
+
        /* allocate the private data structures for all ports */
        /* number of regular ports + 1 for the out-of-band port */
        for (i = 0; i < serial->type->num_ports + 1; i++) {