]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/mousedev.c
saner FASYNC handling on file close
[linux-2.6-omap-h63xx.git] / drivers / input / mousedev.c
index b989748598ae2191cc58f806eb11a19290b847fe..d8c056fe7e982c2ee1f1dc39298e0e4721a06921 100644 (file)
@@ -14,6 +14,7 @@
 #define MOUSEDEV_MIX           31
 
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -518,7 +519,6 @@ static int mousedev_release(struct inode *inode, struct file *file)
        struct mousedev_client *client = file->private_data;
        struct mousedev *mousedev = client->mousedev;
 
-       mousedev_fasync(-1, file, 0);
        mousedev_detach_client(mousedev, client);
        kfree(client);
 
@@ -545,16 +545,21 @@ static int mousedev_open(struct inode *inode, struct file *file)
        if (i >= MOUSEDEV_MINORS)
                return -ENODEV;
 
+       lock_kernel();
        error = mutex_lock_interruptible(&mousedev_table_mutex);
-       if (error)
+       if (error) {
+               unlock_kernel();
                return error;
+       }
        mousedev = mousedev_table[i];
        if (mousedev)
                get_device(&mousedev->dev);
        mutex_unlock(&mousedev_table_mutex);
 
-       if (!mousedev)
+       if (!mousedev) {
+               unlock_kernel();
                return -ENODEV;
+       }
 
        client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
        if (!client) {
@@ -573,6 +578,7 @@ static int mousedev_open(struct inode *inode, struct file *file)
                goto err_free_client;
 
        file->private_data = client;
+       unlock_kernel();
        return 0;
 
  err_free_client:
@@ -580,6 +586,7 @@ static int mousedev_open(struct inode *inode, struct file *file)
        kfree(client);
  err_put_mousedev:
        put_device(&mousedev->dev);
+       unlock_kernel();
        return error;
 }