aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/adb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/macintosh/adb.c')
-rw-r--r--drivers/macintosh/adb.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 61b62a6f681b..e5d446804d32 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -643,12 +643,18 @@ do_adb_query(struct adb_request *req)
643static int adb_open(struct inode *inode, struct file *file) 643static int adb_open(struct inode *inode, struct file *file)
644{ 644{
645 struct adbdev_state *state; 645 struct adbdev_state *state;
646 int ret = 0;
646 647
647 if (iminor(inode) > 0 || adb_controller == NULL) 648 lock_kernel();
648 return -ENXIO; 649 if (iminor(inode) > 0 || adb_controller == NULL) {
650 ret = -ENXIO;
651 goto out;
652 }
649 state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL); 653 state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
650 if (state == 0) 654 if (state == 0) {
651 return -ENOMEM; 655 ret = -ENOMEM;
656 goto out;
657 }
652 file->private_data = state; 658 file->private_data = state;
653 spin_lock_init(&state->lock); 659 spin_lock_init(&state->lock);
654 atomic_set(&state->n_pending, 0); 660 atomic_set(&state->n_pending, 0);
@@ -656,7 +662,9 @@ static int adb_open(struct inode *inode, struct file *file)
656 init_waitqueue_head(&state->wait_queue); 662 init_waitqueue_head(&state->wait_queue);
657 state->inuse = 1; 663 state->inuse = 1;
658 664
659 return 0; 665out:
666 unlock_kernel();
667 return ret;
660} 668}
661 669
662static int adb_release(struct inode *inode, struct file *file) 670static int adb_release(struct inode *inode, struct file *file)