aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc/ldusb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/misc/ldusb.c')
-rw-r--r--drivers/usb/misc/ldusb.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 7c0bd13eccb2..8de32df5978a 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -33,6 +33,7 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/mutex.h> 35#include <linux/mutex.h>
36#include <linux/smp_lock.h>
36 37
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38#include <linux/input.h> 39#include <linux/input.h>
@@ -296,12 +297,14 @@ static int ld_usb_open(struct inode *inode, struct file *file)
296 int retval; 297 int retval;
297 struct usb_interface *interface; 298 struct usb_interface *interface;
298 299
300 lock_kernel();
299 nonseekable_open(inode, file); 301 nonseekable_open(inode, file);
300 subminor = iminor(inode); 302 subminor = iminor(inode);
301 303
302 interface = usb_find_interface(&ld_usb_driver, subminor); 304 interface = usb_find_interface(&ld_usb_driver, subminor);
303 305
304 if (!interface) { 306 if (!interface) {
307 unlock_kernel();
305 err("%s - error, can't find device for minor %d\n", 308 err("%s - error, can't find device for minor %d\n",
306 __func__, subminor); 309 __func__, subminor);
307 return -ENODEV; 310 return -ENODEV;
@@ -309,12 +312,16 @@ static int ld_usb_open(struct inode *inode, struct file *file)
309 312
310 dev = usb_get_intfdata(interface); 313 dev = usb_get_intfdata(interface);
311 314
312 if (!dev) 315 if (!dev) {
316 unlock_kernel();
313 return -ENODEV; 317 return -ENODEV;
318 }
314 319
315 /* lock this device */ 320 /* lock this device */
316 if (mutex_lock_interruptible(&dev->mutex)) 321 if (mutex_lock_interruptible(&dev->mutex)) {
322 unlock_kernel();
317 return -ERESTARTSYS; 323 return -ERESTARTSYS;
324 }
318 325
319 /* allow opening only once */ 326 /* allow opening only once */
320 if (dev->open_count) { 327 if (dev->open_count) {
@@ -353,6 +360,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
353 360
354unlock_exit: 361unlock_exit:
355 mutex_unlock(&dev->mutex); 362 mutex_unlock(&dev->mutex);
363 unlock_kernel();
356 364
357 return retval; 365 return retval;
358} 366}