diff options
Diffstat (limited to 'drivers/usb/misc/usblcd.c')
-rw-r--r-- | drivers/usb/misc/usblcd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index ada2ebc464ae..887ef953f3d8 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -47,6 +47,7 @@ struct usb_lcd { | |||
47 | #define to_lcd_dev(d) container_of(d, struct usb_lcd, kref) | 47 | #define to_lcd_dev(d) container_of(d, struct usb_lcd, kref) |
48 | 48 | ||
49 | static struct usb_driver lcd_driver; | 49 | static struct usb_driver lcd_driver; |
50 | static DEFINE_MUTEX(usb_lcd_open_mutex); | ||
50 | 51 | ||
51 | 52 | ||
52 | static void lcd_delete(struct kref *kref) | 53 | static void lcd_delete(struct kref *kref) |
@@ -68,6 +69,7 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
68 | 69 | ||
69 | subminor = iminor(inode); | 70 | subminor = iminor(inode); |
70 | 71 | ||
72 | mutex_lock(&usb_lcd_open_mutex); | ||
71 | interface = usb_find_interface(&lcd_driver, subminor); | 73 | interface = usb_find_interface(&lcd_driver, subminor); |
72 | if (!interface) { | 74 | if (!interface) { |
73 | err ("USBLCD: %s - error, can't find device for minor %d", | 75 | err ("USBLCD: %s - error, can't find device for minor %d", |
@@ -89,6 +91,7 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
89 | file->private_data = dev; | 91 | file->private_data = dev; |
90 | 92 | ||
91 | exit: | 93 | exit: |
94 | mutex_unlock(&usb_lcd_open_mutex); | ||
92 | return retval; | 95 | return retval; |
93 | } | 96 | } |
94 | 97 | ||
@@ -347,7 +350,7 @@ static void lcd_disconnect(struct usb_interface *interface) | |||
347 | int minor = interface->minor; | 350 | int minor = interface->minor; |
348 | 351 | ||
349 | /* prevent skel_open() from racing skel_disconnect() */ | 352 | /* prevent skel_open() from racing skel_disconnect() */ |
350 | lock_kernel(); | 353 | mutex_lock(&usb_lcd_open_mutex); |
351 | 354 | ||
352 | dev = usb_get_intfdata(interface); | 355 | dev = usb_get_intfdata(interface); |
353 | usb_set_intfdata(interface, NULL); | 356 | usb_set_intfdata(interface, NULL); |
@@ -355,7 +358,7 @@ static void lcd_disconnect(struct usb_interface *interface) | |||
355 | /* give back our minor */ | 358 | /* give back our minor */ |
356 | usb_deregister_dev(interface, &lcd_class); | 359 | usb_deregister_dev(interface, &lcd_class); |
357 | 360 | ||
358 | unlock_kernel(); | 361 | mutex_unlock(&usb_lcd_open_mutex); |
359 | 362 | ||
360 | /* decrement our usage count */ | 363 | /* decrement our usage count */ |
361 | kref_put(&dev->kref, lcd_delete); | 364 | kref_put(&dev->kref, lcd_delete); |