diff options
author | Oliver Neukum <oliver@neukum.org> | 2010-01-13 09:33:15 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-02 17:54:23 -0500 |
commit | 86266452f80545285c14e20a8024f79c4fb88a86 (patch) | |
tree | ebb0a287f9bf189737d4924536d18b36492fd330 /drivers/usb/misc | |
parent | f9de332ebf9df71892d52f7eb64af101a647349f (diff) |
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>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/adutux.c | 3 | ||||
-rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 15 | ||||
-rw-r--r-- | drivers/usb/misc/idmouse.c | 8 | ||||
-rw-r--r-- | drivers/usb/misc/iowarrior.c | 4 | ||||
-rw-r--r-- | drivers/usb/misc/ldusb.c | 12 | ||||
-rw-r--r-- | drivers/usb/misc/legousbtower.c | 3 | ||||
-rw-r--r-- | drivers/usb/misc/rio500.c | 3 | ||||
-rw-r--r-- | drivers/usb/misc/sisusbvga/sisusb.c | 14 | ||||
-rw-r--r-- | drivers/usb/misc/usblcd.c | 5 | ||||
-rw-r--r-- | drivers/usb/misc/vstusb.c | 9 |
10 files changed, 66 insertions, 10 deletions
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 306e97825b36..ac8ad91c2dac 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/usb.h> | 26 | #include <linux/usb.h> |
27 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/smp_lock.h> | ||
28 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
29 | 30 | ||
30 | #ifdef CONFIG_USB_DEBUG | 31 | #ifdef CONFIG_USB_DEBUG |
@@ -274,6 +275,7 @@ static int adu_open(struct inode *inode, struct file *file) | |||
274 | 275 | ||
275 | dbg(2,"%s : enter", __func__); | 276 | dbg(2,"%s : enter", __func__); |
276 | 277 | ||
278 | lock_kernel(); | ||
277 | subminor = iminor(inode); | 279 | subminor = iminor(inode); |
278 | 280 | ||
279 | if ((retval = mutex_lock_interruptible(&adutux_mutex))) { | 281 | if ((retval = mutex_lock_interruptible(&adutux_mutex))) { |
@@ -332,6 +334,7 @@ static int adu_open(struct inode *inode, struct file *file) | |||
332 | exit_no_device: | 334 | exit_no_device: |
333 | mutex_unlock(&adutux_mutex); | 335 | mutex_unlock(&adutux_mutex); |
334 | exit_no_lock: | 336 | exit_no_lock: |
337 | unlock_kernel(); | ||
335 | dbg(2,"%s : leave, return value %d ", __func__, retval); | 338 | dbg(2,"%s : leave, return value %d ", __func__, retval); |
336 | return retval; | 339 | return retval; |
337 | } | 340 | } |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index f21bf5160f83..32c47fbee288 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
46 | #include <linux/kref.h> | 46 | #include <linux/kref.h> |
47 | #include <linux/mutex.h> | 47 | #include <linux/mutex.h> |
48 | #include <linux/smp_lock.h> | ||
48 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
49 | #include <linux/usb.h> | 50 | #include <linux/usb.h> |
50 | #include <linux/workqueue.h> | 51 | #include <linux/workqueue.h> |
@@ -623,22 +624,30 @@ static void ftdi_elan_status_work(struct work_struct *work) | |||
623 | */ | 624 | */ |
624 | static int ftdi_elan_open(struct inode *inode, struct file *file) | 625 | static int ftdi_elan_open(struct inode *inode, struct file *file) |
625 | { | 626 | { |
626 | int subminor = iminor(inode); | 627 | int subminor; |
627 | struct usb_interface *interface = usb_find_interface(&ftdi_elan_driver, | 628 | struct usb_interface *interface; |
628 | subminor); | 629 | |
630 | lock_kernel(); | ||
631 | subminor = iminor(inode); | ||
632 | interface = usb_find_interface(&ftdi_elan_driver, subminor); | ||
633 | |||
629 | if (!interface) { | 634 | if (!interface) { |
635 | unlock_kernel(); | ||
630 | printk(KERN_ERR "can't find device for minor %d\n", subminor); | 636 | printk(KERN_ERR "can't find device for minor %d\n", subminor); |
631 | return -ENODEV; | 637 | return -ENODEV; |
632 | } else { | 638 | } else { |
633 | struct usb_ftdi *ftdi = usb_get_intfdata(interface); | 639 | struct usb_ftdi *ftdi = usb_get_intfdata(interface); |
634 | if (!ftdi) { | 640 | if (!ftdi) { |
641 | unlock_kernel(); | ||
635 | return -ENODEV; | 642 | return -ENODEV; |
636 | } else { | 643 | } else { |
637 | if (down_interruptible(&ftdi->sw_lock)) { | 644 | if (down_interruptible(&ftdi->sw_lock)) { |
645 | unlock_kernel(); | ||
638 | return -EINTR; | 646 | return -EINTR; |
639 | } else { | 647 | } else { |
640 | ftdi_elan_get_kref(ftdi); | 648 | ftdi_elan_get_kref(ftdi); |
641 | file->private_data = ftdi; | 649 | file->private_data = ftdi; |
650 | unlock_kernel(); | ||
642 | return 0; | 651 | return 0; |
643 | } | 652 | } |
644 | } | 653 | } |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index a54c3cb804ce..68df9ac76699 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/completion.h> | 25 | #include <linux/completion.h> |
26 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
27 | #include <linux/smp_lock.h> | ||
27 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
28 | #include <linux/usb.h> | 29 | #include <linux/usb.h> |
29 | 30 | ||
@@ -226,16 +227,20 @@ static int idmouse_open(struct inode *inode, struct file *file) | |||
226 | struct usb_interface *interface; | 227 | struct usb_interface *interface; |
227 | int result; | 228 | int result; |
228 | 229 | ||
230 | lock_kernel(); | ||
229 | /* get the interface from minor number and driver information */ | 231 | /* get the interface from minor number and driver information */ |
230 | interface = usb_find_interface (&idmouse_driver, iminor (inode)); | 232 | interface = usb_find_interface (&idmouse_driver, iminor (inode)); |
231 | if (!interface) | 233 | if (!interface) { |
234 | unlock_kernel(); | ||
232 | return -ENODEV; | 235 | return -ENODEV; |
236 | } | ||
233 | 237 | ||
234 | mutex_lock(&open_disc_mutex); | 238 | mutex_lock(&open_disc_mutex); |
235 | /* get the device information block from the interface */ | 239 | /* get the device information block from the interface */ |
236 | dev = usb_get_intfdata(interface); | 240 | dev = usb_get_intfdata(interface); |
237 | if (!dev) { | 241 | if (!dev) { |
238 | mutex_unlock(&open_disc_mutex); | 242 | mutex_unlock(&open_disc_mutex); |
243 | unlock_kernel(); | ||
239 | return -ENODEV; | 244 | return -ENODEV; |
240 | } | 245 | } |
241 | 246 | ||
@@ -272,6 +277,7 @@ error: | |||
272 | 277 | ||
273 | /* unlock this device */ | 278 | /* unlock this device */ |
274 | mutex_unlock(&dev->lock); | 279 | mutex_unlock(&dev->lock); |
280 | unlock_kernel(); | ||
275 | return result; | 281 | return result; |
276 | } | 282 | } |
277 | 283 | ||
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 5206423211fb..d3c852363883 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -602,10 +602,12 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
602 | 602 | ||
603 | dbg("%s", __func__); | 603 | dbg("%s", __func__); |
604 | 604 | ||
605 | lock_kernel(); | ||
605 | subminor = iminor(inode); | 606 | subminor = iminor(inode); |
606 | 607 | ||
607 | interface = usb_find_interface(&iowarrior_driver, subminor); | 608 | interface = usb_find_interface(&iowarrior_driver, subminor); |
608 | if (!interface) { | 609 | if (!interface) { |
610 | unlock_kernel(); | ||
609 | err("%s - error, can't find device for minor %d", __func__, | 611 | err("%s - error, can't find device for minor %d", __func__, |
610 | subminor); | 612 | subminor); |
611 | return -ENODEV; | 613 | return -ENODEV; |
@@ -615,6 +617,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
615 | dev = usb_get_intfdata(interface); | 617 | dev = usb_get_intfdata(interface); |
616 | if (!dev) { | 618 | if (!dev) { |
617 | mutex_unlock(&iowarrior_open_disc_lock); | 619 | mutex_unlock(&iowarrior_open_disc_lock); |
620 | unlock_kernel(); | ||
618 | return -ENODEV; | 621 | return -ENODEV; |
619 | } | 622 | } |
620 | 623 | ||
@@ -641,6 +644,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
641 | 644 | ||
642 | out: | 645 | out: |
643 | mutex_unlock(&dev->mutex); | 646 | mutex_unlock(&dev->mutex); |
647 | unlock_kernel(); | ||
644 | return retval; | 648 | return retval; |
645 | } | 649 | } |
646 | 650 | ||
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 | ||
354 | unlock_exit: | 361 | unlock_exit: |
355 | mutex_unlock(&dev->mutex); | 362 | mutex_unlock(&dev->mutex); |
363 | unlock_kernel(); | ||
356 | 364 | ||
357 | return retval; | 365 | return retval; |
358 | } | 366 | } |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 3d4378fb4410..94e1b84134dd 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -82,6 +82,7 @@ | |||
82 | #include <linux/module.h> | 82 | #include <linux/module.h> |
83 | #include <linux/completion.h> | 83 | #include <linux/completion.h> |
84 | #include <linux/mutex.h> | 84 | #include <linux/mutex.h> |
85 | #include <linux/smp_lock.h> | ||
85 | #include <asm/uaccess.h> | 86 | #include <asm/uaccess.h> |
86 | #include <linux/usb.h> | 87 | #include <linux/usb.h> |
87 | #include <linux/poll.h> | 88 | #include <linux/poll.h> |
@@ -345,6 +346,7 @@ static int tower_open (struct inode *inode, struct file *file) | |||
345 | 346 | ||
346 | dbg(2, "%s: enter", __func__); | 347 | dbg(2, "%s: enter", __func__); |
347 | 348 | ||
349 | lock_kernel(); | ||
348 | nonseekable_open(inode, file); | 350 | nonseekable_open(inode, file); |
349 | subminor = iminor(inode); | 351 | subminor = iminor(inode); |
350 | 352 | ||
@@ -430,6 +432,7 @@ unlock_exit: | |||
430 | mutex_unlock(&dev->lock); | 432 | mutex_unlock(&dev->lock); |
431 | 433 | ||
432 | exit: | 434 | exit: |
435 | unlock_kernel(); | ||
433 | dbg(2, "%s: leave, return value %d ", __func__, retval); | 436 | dbg(2, "%s: leave, return value %d ", __func__, retval); |
434 | 437 | ||
435 | return retval; | 438 | return retval; |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 17e4eecaee73..47ce46bb5b01 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -77,7 +77,7 @@ static struct rio_usb_data rio_instance; | |||
77 | static int open_rio(struct inode *inode, struct file *file) | 77 | static int open_rio(struct inode *inode, struct file *file) |
78 | { | 78 | { |
79 | struct rio_usb_data *rio = &rio_instance; | 79 | struct rio_usb_data *rio = &rio_instance; |
80 | 80 | lock_kernel(); | |
81 | mutex_lock(&(rio->lock)); | 81 | mutex_lock(&(rio->lock)); |
82 | 82 | ||
83 | if (rio->isopen || !rio->present) { | 83 | if (rio->isopen || !rio->present) { |
@@ -91,6 +91,7 @@ static int open_rio(struct inode *inode, struct file *file) | |||
91 | mutex_unlock(&(rio->lock)); | 91 | mutex_unlock(&(rio->lock)); |
92 | 92 | ||
93 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); | 93 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); |
94 | unlock_kernel(); | ||
94 | 95 | ||
95 | return 0; | 96 | return 0; |
96 | } | 97 | } |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index bb0b315b521d..3991655f8f09 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -2416,21 +2416,28 @@ sisusb_open(struct inode *inode, struct file *file) | |||
2416 | struct usb_interface *interface; | 2416 | struct usb_interface *interface; |
2417 | int subminor = iminor(inode); | 2417 | int subminor = iminor(inode); |
2418 | 2418 | ||
2419 | if (!(interface = usb_find_interface(&sisusb_driver, subminor))) | 2419 | lock_kernel(); |
2420 | if (!(interface = usb_find_interface(&sisusb_driver, subminor))) { | ||
2421 | unlock_kernel(); | ||
2420 | return -ENODEV; | 2422 | return -ENODEV; |
2423 | } | ||
2421 | 2424 | ||
2422 | if (!(sisusb = usb_get_intfdata(interface))) | 2425 | if (!(sisusb = usb_get_intfdata(interface))) { |
2426 | unlock_kernel(); | ||
2423 | return -ENODEV; | 2427 | return -ENODEV; |
2428 | } | ||
2424 | 2429 | ||
2425 | mutex_lock(&sisusb->lock); | 2430 | mutex_lock(&sisusb->lock); |
2426 | 2431 | ||
2427 | if (!sisusb->present || !sisusb->ready) { | 2432 | if (!sisusb->present || !sisusb->ready) { |
2428 | mutex_unlock(&sisusb->lock); | 2433 | mutex_unlock(&sisusb->lock); |
2434 | unlock_kernel(); | ||
2429 | return -ENODEV; | 2435 | return -ENODEV; |
2430 | } | 2436 | } |
2431 | 2437 | ||
2432 | if (sisusb->isopen) { | 2438 | if (sisusb->isopen) { |
2433 | mutex_unlock(&sisusb->lock); | 2439 | mutex_unlock(&sisusb->lock); |
2440 | unlock_kernel(); | ||
2434 | return -EBUSY; | 2441 | return -EBUSY; |
2435 | } | 2442 | } |
2436 | 2443 | ||
@@ -2439,11 +2446,13 @@ sisusb_open(struct inode *inode, struct file *file) | |||
2439 | if (sisusb_init_gfxdevice(sisusb, 0)) { | 2446 | if (sisusb_init_gfxdevice(sisusb, 0)) { |
2440 | mutex_unlock(&sisusb->lock); | 2447 | mutex_unlock(&sisusb->lock); |
2441 | dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); | 2448 | dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); |
2449 | unlock_kernel(); | ||
2442 | return -EIO; | 2450 | return -EIO; |
2443 | } | 2451 | } |
2444 | } else { | 2452 | } else { |
2445 | mutex_unlock(&sisusb->lock); | 2453 | mutex_unlock(&sisusb->lock); |
2446 | dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n"); | 2454 | dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n"); |
2455 | unlock_kernel(); | ||
2447 | return -EIO; | 2456 | return -EIO; |
2448 | } | 2457 | } |
2449 | } | 2458 | } |
@@ -2456,6 +2465,7 @@ sisusb_open(struct inode *inode, struct file *file) | |||
2456 | file->private_data = sisusb; | 2465 | file->private_data = sisusb; |
2457 | 2466 | ||
2458 | mutex_unlock(&sisusb->lock); | 2467 | mutex_unlock(&sisusb->lock); |
2468 | unlock_kernel(); | ||
2459 | 2469 | ||
2460 | return 0; | 2470 | return 0; |
2461 | } | 2471 | } |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 499d7508be9a..90aede90553e 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -74,10 +74,12 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
74 | struct usb_interface *interface; | 74 | struct usb_interface *interface; |
75 | int subminor, r; | 75 | int subminor, r; |
76 | 76 | ||
77 | lock_kernel(); | ||
77 | subminor = iminor(inode); | 78 | subminor = iminor(inode); |
78 | 79 | ||
79 | interface = usb_find_interface(&lcd_driver, subminor); | 80 | interface = usb_find_interface(&lcd_driver, subminor); |
80 | if (!interface) { | 81 | if (!interface) { |
82 | unlock_kernel(); | ||
81 | err ("USBLCD: %s - error, can't find device for minor %d", | 83 | err ("USBLCD: %s - error, can't find device for minor %d", |
82 | __func__, subminor); | 84 | __func__, subminor); |
83 | return -ENODEV; | 85 | return -ENODEV; |
@@ -87,6 +89,7 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
87 | dev = usb_get_intfdata(interface); | 89 | dev = usb_get_intfdata(interface); |
88 | if (!dev) { | 90 | if (!dev) { |
89 | mutex_unlock(&open_disc_mutex); | 91 | mutex_unlock(&open_disc_mutex); |
92 | unlock_kernel(); | ||
90 | return -ENODEV; | 93 | return -ENODEV; |
91 | } | 94 | } |
92 | 95 | ||
@@ -98,11 +101,13 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
98 | r = usb_autopm_get_interface(interface); | 101 | r = usb_autopm_get_interface(interface); |
99 | if (r < 0) { | 102 | if (r < 0) { |
100 | kref_put(&dev->kref, lcd_delete); | 103 | kref_put(&dev->kref, lcd_delete); |
104 | unlock_kernel(); | ||
101 | return r; | 105 | return r; |
102 | } | 106 | } |
103 | 107 | ||
104 | /* save our object in the file's private structure */ | 108 | /* save our object in the file's private structure */ |
105 | file->private_data = dev; | 109 | file->private_data = dev; |
110 | unlock_kernel(); | ||
106 | 111 | ||
107 | return 0; | 112 | return 0; |
108 | } | 113 | } |
diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c index 874c81bb27b9..b787b25d4cc4 100644 --- a/drivers/usb/misc/vstusb.c +++ b/drivers/usb/misc/vstusb.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
30 | #include <linux/smp_lock.h> | ||
30 | #include <linux/uaccess.h> | 31 | #include <linux/uaccess.h> |
31 | #include <linux/usb.h> | 32 | #include <linux/usb.h> |
32 | 33 | ||
@@ -103,19 +104,23 @@ static int vstusb_open(struct inode *inode, struct file *file) | |||
103 | struct vstusb_device *vstdev; | 104 | struct vstusb_device *vstdev; |
104 | struct usb_interface *interface; | 105 | struct usb_interface *interface; |
105 | 106 | ||
107 | lock_kernel(); | ||
106 | interface = usb_find_interface(&vstusb_driver, iminor(inode)); | 108 | interface = usb_find_interface(&vstusb_driver, iminor(inode)); |
107 | 109 | ||
108 | if (!interface) { | 110 | if (!interface) { |
109 | printk(KERN_ERR KBUILD_MODNAME | 111 | printk(KERN_ERR KBUILD_MODNAME |
110 | ": %s - error, can't find device for minor %d\n", | 112 | ": %s - error, can't find device for minor %d\n", |
111 | __func__, iminor(inode)); | 113 | __func__, iminor(inode)); |
114 | unlock_kernel(); | ||
112 | return -ENODEV; | 115 | return -ENODEV; |
113 | } | 116 | } |
114 | 117 | ||
115 | vstdev = usb_get_intfdata(interface); | 118 | vstdev = usb_get_intfdata(interface); |
116 | 119 | ||
117 | if (!vstdev) | 120 | if (!vstdev) { |
121 | unlock_kernel(); | ||
118 | return -ENODEV; | 122 | return -ENODEV; |
123 | } | ||
119 | 124 | ||
120 | /* lock this device */ | 125 | /* lock this device */ |
121 | mutex_lock(&vstdev->lock); | 126 | mutex_lock(&vstdev->lock); |
@@ -123,6 +128,7 @@ static int vstusb_open(struct inode *inode, struct file *file) | |||
123 | /* can only open one time */ | 128 | /* can only open one time */ |
124 | if ((!vstdev->present) || (vstdev->isopen)) { | 129 | if ((!vstdev->present) || (vstdev->isopen)) { |
125 | mutex_unlock(&vstdev->lock); | 130 | mutex_unlock(&vstdev->lock); |
131 | unlock_kernel(); | ||
126 | return -EBUSY; | 132 | return -EBUSY; |
127 | } | 133 | } |
128 | 134 | ||
@@ -137,6 +143,7 @@ static int vstusb_open(struct inode *inode, struct file *file) | |||
137 | dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__); | 143 | dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__); |
138 | 144 | ||
139 | mutex_unlock(&vstdev->lock); | 145 | mutex_unlock(&vstdev->lock); |
146 | unlock_kernel(); | ||
140 | 147 | ||
141 | return 0; | 148 | return 0; |
142 | } | 149 | } |