Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100408
b: refs/heads/master
c: feae1ef
h: refs/heads/master
v: v3
  • Loading branch information
Roland Dreier authored and Jonathan Corbet committed Jul 11, 2008
1 parent dde13c2 commit 5fbc1e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 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: 5b2d281acb04a29fcdc76ced5ca6099565a0747f
refs/heads/master: feae1ef116ed381625d3731c5ae4f4ebcb3fa302
20 changes: 14 additions & 6 deletions trunk/drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#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 @@ -778,23 +777,33 @@ static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd,
}
#endif

/*
* ib_umad_open() does not need the BKL:
*
* - umad_port[] accesses are protected by port_lock, the
* ib_umad_port 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;
* - the ioctl method does not affect any global state outside of the
* file structure being operated on;
* - the port is added to umad_port[] as the last part of module
* initialization so the open method will either immediately run
* -ENXIO, or all required initialization will be done.
*/
static int ib_umad_open(struct inode *inode, struct file *filp)
{
struct ib_umad_port *port;
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) {
unlock_kernel();
if (!port)
return -ENXIO;
}

mutex_lock(&port->file_mutex);

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

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

Expand Down

0 comments on commit 5fbc1e9

Please sign in to comment.