USB: ldusb should signal an error in poll if the device is disconnected
authorOliver Neukum <oliver@neukum.org>
Thu, 2 Jul 2009 15:01:06 +0000 (17:01 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 23 Sep 2009 13:46:28 +0000 (06:46 -0700)
poll() should test for a disconnection of the device.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/misc/ldusb.c

index ad4fb15b5dcbcaa6a12b26037880e4121900d9a2..90f130126c10d605db2115ee6c16afe8329266cb 100644 (file)
@@ -412,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);
 
@@ -767,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);
        }