]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/hid/hidraw.c
HID: hidraw, uhid: Always report EPOLLOUT
[mirror_ubuntu-bionic-kernel.git] / drivers / hid / hidraw.c
index 5fbe0f81ab2ebd2c972237fa1be2bc3b544afee8..5243c412081917e2f452e48bd01d48539595ef4a 100644 (file)
@@ -192,6 +192,11 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
        int ret = 0, len;
        unsigned char report_number;
 
+       if (!hidraw_table[minor] || !hidraw_table[minor]->exist) {
+               ret = -ENODEV;
+               goto out;
+       }
+
        dev = hidraw_table[minor]->hid;
 
        if (!dev->ll_driver->raw_request) {
@@ -252,13 +257,14 @@ out:
 static unsigned int hidraw_poll(struct file *file, poll_table *wait)
 {
        struct hidraw_list *list = file->private_data;
+       unsigned int mask = POLLOUT | POLLWRNORM; /* hidraw is always writable */
 
        poll_wait(file, &list->hidraw->wait, wait);
        if (list->head != list->tail)
-               return POLLIN | POLLRDNORM;
+               mask |= POLLIN | POLLRDNORM;
        if (!list->hidraw->exist)
-               return POLLERR | POLLHUP;
-       return 0;
+               mask |= POLLERR | POLLHUP;
+       return mask;
 }
 
 static int hidraw_open(struct inode *inode, struct file *file)
@@ -373,7 +379,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
 
        mutex_lock(&minors_lock);
        dev = hidraw_table[minor];
-       if (!dev) {
+       if (!dev || !dev->exist) {
                ret = -ENODEV;
                goto out;
        }