[PATCH 2/11] drivers/watchdog: Eliminate a NULL pointer dereference
[safe/jmp/linux-2.6] / drivers / usb / misc / ldusb.c
index 7aafd53..dd41d87 100644 (file)
 #define USB_DEVICE_ID_LD_MACHINETEST   0x2040  /* USB Product ID of Machine Test System */
 
 #define USB_VENDOR_ID_VERNIER          0x08f7
-#define USB_DEVICE_ID_VERNIER_LABPRO   0x0001
 #define USB_DEVICE_ID_VERNIER_GOTEMP   0x0002
 #define USB_DEVICE_ID_VERNIER_SKIP     0x0003
 #define USB_DEVICE_ID_VERNIER_CYCLOPS  0x0004
 #define USB_DEVICE_ID_VERNIER_LCSPEC   0x0006
 
-#define USB_VENDOR_ID_MICROCHIP                0x04d8
-#define USB_DEVICE_ID_PICDEM           0x000c
-
 #ifdef CONFIG_USB_DYNAMIC_MINORS
 #define USB_LD_MINOR_BASE      0
 #else
@@ -73,7 +69,7 @@
 #endif
 
 /* table of devices that work with this driver */
-static struct usb_device_id ld_usb_table [] = {
+static const struct usb_device_id ld_usb_table[] = {
        { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
        { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
        { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
@@ -88,11 +84,9 @@ static struct usb_device_id ld_usb_table [] = {
        { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
        { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
        { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
-       { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
        { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
        { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
        { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
-       { USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICDEM) },
        { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
        { }                                     /* Terminating entry */
 };
@@ -418,6 +412,9 @@ static unsigned int ld_usb_poll(struct file *file, poll_table *wait)
 
        dev = file->private_data;
 
+       if (!dev->intf)
+               return POLLERR | POLLHUP;
+
        poll_wait(file, &dev->read_wait, wait);
        poll_wait(file, &dev->write_wait, wait);
 
@@ -773,6 +770,9 @@ static void ld_usb_disconnect(struct usb_interface *intf)
                ld_usb_delete(dev);
        } else {
                dev->intf = NULL;
+               /* wake up pollers */
+               wake_up_interruptible_all(&dev->read_wait);
+               wake_up_interruptible_all(&dev->write_wait);
                mutex_unlock(&dev->mutex);
        }
 
@@ -798,7 +798,7 @@ static int __init ld_usb_init(void)
        /* register this driver with the USB subsystem */
        retval = usb_register(&ld_usb_driver);
        if (retval)
-               err("usb_register failed for the "__FILE__" driver. Error number %d\n", retval);
+               err("usb_register failed for the %s driver. Error number %d\n", __FILE__, retval);
 
        return retval;
 }