Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100407
b: refs/heads/master
c: 5b2d281
h: refs/heads/master
i:
  100405: 3ee3a2b
  100403: ff8553d
  100399: 7f8bf2f
v: v3
  • Loading branch information
Roland Dreier authored and Jonathan Corbet committed Jul 4, 2008
1 parent b2c2642 commit dde13c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 57debddaa1d247ed147209b22b5d40bd97526c33
refs/heads/master: 5b2d281acb04a29fcdc76ced5ca6099565a0747f
20 changes: 13 additions & 7 deletions trunk/drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <linux/file.h>
#include <linux/mount.h>
#include <linux/cdev.h>
#include <linux/smp_lock.h>

#include <asm/uaccess.h>

Expand Down Expand Up @@ -611,23 +610,32 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
return file->device->ib_dev->mmap(file->ucontext, vma);
}

/*
* ib_uverbs_open() does not need the BKL:
*
* - dev_table[] accesses are protected by map_lock, the
* ib_uverbs_device structures are properly reference counted, and
* everything else is purely local to the file being created, so
* races against other open calls are not a problem;
* - there is no ioctl method to race against;
* - the device is added to dev_table[] as the last part of module
* initialization, the open method will either immediately run
* -ENXIO, or all required initialization will be done.
*/
static int ib_uverbs_open(struct inode *inode, struct file *filp)
{
struct ib_uverbs_device *dev;
struct ib_uverbs_file *file;
int ret;

lock_kernel();
spin_lock(&map_lock);
dev = dev_table[iminor(inode) - IB_UVERBS_BASE_MINOR];
if (dev)
kref_get(&dev->ref);
spin_unlock(&map_lock);

if (!dev) {
unlock_kernel();
if (!dev)
return -ENXIO;
}

if (!try_module_get(dev->ib_dev->owner)) {
ret = -ENODEV;
Expand All @@ -648,15 +656,13 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)

filp->private_data = file;

unlock_kernel();
return 0;

err_module:
module_put(dev->ib_dev->owner);

err:
kref_put(&dev->ref, ib_uverbs_release_dev);
unlock_kernel();
return ret;
}

Expand Down

0 comments on commit dde13c2

Please sign in to comment.