infiniband: more BKL pushdown
Be extra-cautious and protect the remaining open() functions. Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
#include <linux/kref.h>
|
#include <linux/kref.h>
|
||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
#include <linux/semaphore.h>
|
#include <linux/semaphore.h>
|
||||||
|
#include <linux/smp_lock.h>
|
||||||
|
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
|
|
||||||
@@ -783,14 +784,17 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
|
|||||||
struct ib_umad_file *file;
|
struct ib_umad_file *file;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
lock_kernel();
|
||||||
spin_lock(&port_lock);
|
spin_lock(&port_lock);
|
||||||
port = umad_port[iminor(inode) - IB_UMAD_MINOR_BASE];
|
port = umad_port[iminor(inode) - IB_UMAD_MINOR_BASE];
|
||||||
if (port)
|
if (port)
|
||||||
kref_get(&port->umad_dev->ref);
|
kref_get(&port->umad_dev->ref);
|
||||||
spin_unlock(&port_lock);
|
spin_unlock(&port_lock);
|
||||||
|
|
||||||
if (!port)
|
if (!port) {
|
||||||
|
unlock_kernel();
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_lock(&port->file_mutex);
|
mutex_lock(&port->file_mutex);
|
||||||
|
|
||||||
@@ -819,6 +823,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&port->file_mutex);
|
mutex_unlock(&port->file_mutex);
|
||||||
|
unlock_kernel();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,6 +45,7 @@
|
|||||||
#include <linux/file.h>
|
#include <linux/file.h>
|
||||||
#include <linux/mount.h>
|
#include <linux/mount.h>
|
||||||
#include <linux/cdev.h>
|
#include <linux/cdev.h>
|
||||||
|
#include <linux/smp_lock.h>
|
||||||
|
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
|
|
||||||
@@ -616,14 +617,17 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
|
|||||||
struct ib_uverbs_file *file;
|
struct ib_uverbs_file *file;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
lock_kernel();
|
||||||
spin_lock(&map_lock);
|
spin_lock(&map_lock);
|
||||||
dev = dev_table[iminor(inode) - IB_UVERBS_BASE_MINOR];
|
dev = dev_table[iminor(inode) - IB_UVERBS_BASE_MINOR];
|
||||||
if (dev)
|
if (dev)
|
||||||
kref_get(&dev->ref);
|
kref_get(&dev->ref);
|
||||||
spin_unlock(&map_lock);
|
spin_unlock(&map_lock);
|
||||||
|
|
||||||
if (!dev)
|
if (!dev) {
|
||||||
|
unlock_kernel();
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
if (!try_module_get(dev->ib_dev->owner)) {
|
if (!try_module_get(dev->ib_dev->owner)) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
@@ -644,6 +648,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
|
|||||||
|
|
||||||
filp->private_data = file;
|
filp->private_data = file;
|
||||||
|
|
||||||
|
unlock_kernel();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_module:
|
err_module:
|
||||||
@@ -651,7 +656,7 @@ err_module:
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
kref_put(&dev->ref, ib_uverbs_release_dev);
|
kref_put(&dev->ref, ib_uverbs_release_dev);
|
||||||
|
unlock_kernel();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user