USB: Push BKL on open down into the drivers
Straightforward push into the drivers to allow
auditing individual drivers separately
Signed-off-by: Oliver Neukum <oliver@neukum.org>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index f21bf51..32c47fb 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -45,6 +45,7 @@
#include <linux/module.h>
#include <linux/kref.h>
#include <linux/mutex.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <linux/usb.h>
#include <linux/workqueue.h>
@@ -623,22 +624,30 @@
*/
static int ftdi_elan_open(struct inode *inode, struct file *file)
{
- int subminor = iminor(inode);
- struct usb_interface *interface = usb_find_interface(&ftdi_elan_driver,
- subminor);
+ int subminor;
+ struct usb_interface *interface;
+
+ lock_kernel();
+ subminor = iminor(inode);
+ interface = usb_find_interface(&ftdi_elan_driver, subminor);
+
if (!interface) {
+ unlock_kernel();
printk(KERN_ERR "can't find device for minor %d\n", subminor);
return -ENODEV;
} else {
struct usb_ftdi *ftdi = usb_get_intfdata(interface);
if (!ftdi) {
+ unlock_kernel();
return -ENODEV;
} else {
if (down_interruptible(&ftdi->sw_lock)) {
+ unlock_kernel();
return -EINTR;
} else {
ftdi_elan_get_kref(ftdi);
file->private_data = ftdi;
+ unlock_kernel();
return 0;
}
}