Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 72588
b: refs/heads/master
c: d5d1cea
h: refs/heads/master
v: v3
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Oct 25, 2007
1 parent 1bac6d6 commit df36eaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 78663ecc344b4694dd737deb682e81312a0684b6
refs/heads/master: d5d1ceac2a47645780bd07fd7a670b14c4d995db
11 changes: 10 additions & 1 deletion trunk/drivers/usb/misc/usblcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <linux/usb.h>

Expand All @@ -34,6 +35,8 @@ static struct usb_device_id id_table [] = {
};
MODULE_DEVICE_TABLE (usb, id_table);

static DEFINE_MUTEX(open_disc_mutex);


struct usb_lcd {
struct usb_device * udev; /* init: probe_lcd */
Expand Down Expand Up @@ -79,12 +82,16 @@ static int lcd_open(struct inode *inode, struct file *file)
return -ENODEV;
}

mutex_lock(&open_disc_mutex);
dev = usb_get_intfdata(interface);
if (!dev)
if (!dev) {
mutex_unlock(&open_disc_mutex);
return -ENODEV;
}

/* increment our usage count for the device */
kref_get(&dev->kref);
mutex_unlock(&open_disc_mutex);

/* grab a power reference */
r = usb_autopm_get_interface(interface);
Expand Down Expand Up @@ -393,8 +400,10 @@ static void lcd_disconnect(struct usb_interface *interface)
struct usb_lcd *dev;
int minor = interface->minor;

mutex_lock(&open_disc_mutex);
dev = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL);
mutex_unlock(&open_disc_mutex);

/* give back our minor */
usb_deregister_dev(interface, &lcd_class);
Expand Down

0 comments on commit df36eaa

Please sign in to comment.