Skip to content

Commit

Permalink
UIO: cdev lock_kernel() pushdown
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Corbet <[email protected]>
  • Loading branch information
Jonathan Corbet committed Jun 20, 2008
1 parent 2edbf85 commit fbc8a81
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions drivers/uio/uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,17 @@ static int uio_open(struct inode *inode, struct file *filep)
struct uio_listener *listener;
int ret = 0;

lock_kernel();
idev = idr_find(&uio_idr, iminor(inode));
if (!idev)
return -ENODEV;
if (!idev) {
ret = -ENODEV;
goto out;
}

if (!try_module_get(idev->owner))
return -ENODEV;
if (!try_module_get(idev->owner)) {
ret = -ENODEV;
goto out;
}

listener = kmalloc(sizeof(*listener), GFP_KERNEL);
if (!listener) {
Expand All @@ -319,7 +324,7 @@ static int uio_open(struct inode *inode, struct file *filep)
if (ret)
goto err_infoopen;
}

unlock_kernel();
return 0;

err_infoopen:
Expand All @@ -329,6 +334,8 @@ static int uio_open(struct inode *inode, struct file *filep)

module_put(idev->owner);

out:
unlock_kernel();
return ret;
}

Expand Down

0 comments on commit fbc8a81

Please sign in to comment.