Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100308
b: refs/heads/master
c: 057e7c7
h: refs/heads/master
v: v3
  • Loading branch information
Jonathan Corbet committed Jun 20, 2008
1 parent c815a4a commit 958b37b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 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: 65f37b790bd7ba15413838579470296a709c45e6
refs/heads/master: 057e7c7ff9f91a36a761588c53826bd6a710aeba
7 changes: 6 additions & 1 deletion trunk/drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <linux/kref.h>
#include <linux/compat.h>
#include <linux/semaphore.h>
#include <linux/smp_lock.h>

#include <asm/uaccess.h>

Expand Down Expand Up @@ -783,14 +784,17 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
struct ib_umad_file *file;
int ret = 0;

lock_kernel();
spin_lock(&port_lock);
port = umad_port[iminor(inode) - IB_UMAD_MINOR_BASE];
if (port)
kref_get(&port->umad_dev->ref);
spin_unlock(&port_lock);

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

mutex_lock(&port->file_mutex);

Expand Down Expand Up @@ -819,6 +823,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)

out:
mutex_unlock(&port->file_mutex);
unlock_kernel();
return ret;
}

Expand Down
9 changes: 7 additions & 2 deletions trunk/drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#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 @@ -616,14 +617,17 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
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)
if (!dev) {
unlock_kernel();
return -ENXIO;
}

if (!try_module_get(dev->ib_dev->owner)) {
ret = -ENODEV;
Expand All @@ -644,14 +648,15 @@ 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 958b37b

Please sign in to comment.