Skip to content

Commit

Permalink
phantom: BKL pushdown
Browse files Browse the repository at this point in the history
Add explicit lock_kernel calls to phantom_open().

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Jonathan Corbet committed Jun 20, 2008
1 parent 057e7c7 commit 4541b5e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/misc/phantom.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/interrupt.h>
#include <linux/cdev.h>
#include <linux/phantom.h>
#include <linux/smp_lock.h>

#include <asm/atomic.h>
#include <asm/io.h>
Expand Down Expand Up @@ -212,13 +213,17 @@ static int phantom_open(struct inode *inode, struct file *file)
struct phantom_device *dev = container_of(inode->i_cdev,
struct phantom_device, cdev);

lock_kernel();
nonseekable_open(inode, file);

if (mutex_lock_interruptible(&dev->open_lock))
if (mutex_lock_interruptible(&dev->open_lock)) {
unlock_kernel();
return -ERESTARTSYS;
}

if (dev->opened) {
mutex_unlock(&dev->open_lock);
unlock_kernel();
return -EINVAL;
}

Expand All @@ -229,7 +234,7 @@ static int phantom_open(struct inode *inode, struct file *file)
atomic_set(&dev->counter, 0);
dev->opened++;
mutex_unlock(&dev->open_lock);

unlock_kernel();
return 0;
}

Expand Down

0 comments on commit 4541b5e

Please sign in to comment.