Skip to content

Commit

Permalink
mousedev: BKL pushdown
Browse files Browse the repository at this point in the history
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
  • Loading branch information
Arnd Bergmann authored and Jonathan Corbet committed Jul 2, 2008
1 parent dca67e9 commit f9c8154
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/input/mousedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -545,16 +546,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) {
Expand All @@ -573,13 +579,15 @@ 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:
mousedev_detach_client(mousedev, client);
kfree(client);
err_put_mousedev:
put_device(&mousedev->dev);
unlock_kernel();
return error;
}

Expand Down

0 comments on commit f9c8154

Please sign in to comment.