]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/hid/hidraw.c
Merge branches 'upstream' and 'upstream-fixes' into for-linus
[net-next-2.6.git] / drivers / hid / hidraw.c
index 47d70c523d93474a658bbaa5aa5b1cfb327f194b..8a4b32dca9f74fd03621f3deffe0912929ee5cf3 100644 (file)
@@ -109,6 +109,12 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
        int ret = 0;
 
        mutex_lock(&minors_lock);
+
+       if (!hidraw_table[minor]) {
+               ret = -ENODEV;
+               goto out;
+       }
+
        dev = hidraw_table[minor]->hid;
 
        if (!dev->hid_output_raw_report) {
@@ -212,9 +218,13 @@ static int hidraw_release(struct inode * inode, struct file * file)
        unsigned int minor = iminor(inode);
        struct hidraw *dev;
        struct hidraw_list *list = file->private_data;
+       int ret;
 
-       if (!hidraw_table[minor])
-               return -ENODEV;
+       mutex_lock(&minors_lock);
+       if (!hidraw_table[minor]) {
+               ret = -ENODEV;
+               goto unlock;
+       }
 
        list_del(&list->node);
        dev = hidraw_table[minor];
@@ -227,10 +237,12 @@ static int hidraw_release(struct inode * inode, struct file * file)
                        kfree(list->hidraw);
                }
        }
-
        kfree(list);
+       ret = 0;
+unlock:
+       mutex_unlock(&minors_lock);
 
-       return 0;
+       return ret;
 }
 
 static long hidraw_ioctl(struct file *file, unsigned int cmd,
@@ -244,6 +256,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
 
        mutex_lock(&minors_lock);
        dev = hidraw_table[minor];
+       if (!dev) {
+               ret = -ENODEV;
+               goto out;
+       }
 
        switch (cmd) {
                case HIDIOCGRDESCSIZE:
@@ -317,6 +333,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
 
                ret = -ENOTTY;
        }
+out:
        mutex_unlock(&minors_lock);
        return ret;
 }
@@ -329,6 +346,7 @@ static const struct file_operations hidraw_ops = {
        .open =         hidraw_open,
        .release =      hidraw_release,
        .unlocked_ioctl = hidraw_ioctl,
+       .llseek =       noop_llseek,
 };
 
 void hidraw_report_event(struct hid_device *hid, u8 *data, int len)