diff options
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 306e97825b3..ac8ad91c2da 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c @@ -25,6 +25,7 @@ #include <linux/module.h> #include <linux/usb.h> #include <linux/mutex.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> #ifdef CONFIG_USB_DEBUG @@ -274,6 +275,7 @@ static int adu_open(struct inode *inode, struct file *file) dbg(2,"%s : enter", __func__); + lock_kernel(); subminor = iminor(inode); if ((retval = mutex_lock_interruptible(&adutux_mutex))) { @@ -332,6 +334,7 @@ static int adu_open(struct inode *inode, struct file *file) exit_no_device: mutex_unlock(&adutux_mutex); exit_no_lock: + unlock_kernel(); dbg(2,"%s : leave, return value %d ", __func__, retval); return retval; } diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index f21bf5160f8..32c47fbee28 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 void ftdi_elan_status_work(struct work_struct *work) */ 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; } } diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index a54c3cb804c..68df9ac7669 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -24,6 +24,7 @@ #include <linux/module.h> #include <linux/completion.h> #include <linux/mutex.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> #include <linux/usb.h> @@ -226,16 +227,20 @@ static int idmouse_open(struct inode *inode, struct file *file) struct usb_interface *interface; int result; + lock_kernel(); /* get the interface from minor number and driver information */ interface = usb_find_interface (&idmouse_driver, iminor (inode)); - if (!interface) + if (!interface) { + unlock_kernel(); return -ENODEV; + } mutex_lock(&open_disc_mutex); /* get the device information block from the interface */ dev = usb_get_intfdata(interface); if (!dev) { mutex_unlock(&open_disc_mutex); + unlock_kernel(); return -ENODEV; } @@ -272,6 +277,7 @@ error: /* unlock this device */ mutex_unlock(&dev->lock); + unlock_kernel(); return result; } diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 5206423211f..d3c85236388 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) dbg("%s", __func__); + lock_kernel(); subminor = iminor(inode); interface = usb_find_interface(&iowarrior_driver, subminor); if (!interface) { + unlock_kernel(); err("%s - error, can't find device for minor %d", __func__, subminor); return -ENODEV; @@ -615,6 +617,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) dev = usb_get_intfdata(interface); if (!dev) { mutex_unlock(&iowarrior_open_disc_lock); + unlock_kernel(); return -ENODEV; } @@ -641,6 +644,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) out: mutex_unlock(&dev->mutex); + unlock_kernel(); return retval; } diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 7c0bd13eccb..8de32df5978 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -33,6 +33,7 @@ #include <linux/slab.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> #include <linux/input.h> @@ -296,12 +297,14 @@ static int ld_usb_open(struct inode *inode, struct file *file) int retval; struct usb_interface *interface; + lock_kernel(); nonseekable_open(inode, file); subminor = iminor(inode); interface = usb_find_interface(&ld_usb_driver, subminor); if (!interface) { + unlock_kernel(); err("%s - error, can't find device for minor %d\n", __func__, subminor); return -ENODEV; @@ -309,12 +312,16 @@ static int ld_usb_open(struct inode *inode, struct file *file) dev = usb_get_intfdata(interface); - if (!dev) + if (!dev) { + unlock_kernel(); return -ENODEV; + } /* lock this device */ - if (mutex_lock_interruptible(&dev->mutex)) + if (mutex_lock_interruptible(&dev->mutex)) { + unlock_kernel(); return -ERESTARTSYS; + } /* allow opening only once */ if (dev->open_count) { @@ -353,6 +360,7 @@ static int ld_usb_open(struct inode *inode, struct file *file) unlock_exit: mutex_unlock(&dev->mutex); + unlock_kernel(); return retval; } diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 3d4378fb441..94e1b84134d 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -82,6 +82,7 @@ #include <linux/module.h> #include <linux/completion.h> #include <linux/mutex.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> #include <linux/usb.h> #include <linux/poll.h> @@ -345,6 +346,7 @@ static int tower_open (struct inode *inode, struct file *file) dbg(2, "%s: enter", __func__); + lock_kernel(); nonseekable_open(inode, file); subminor = iminor(inode); @@ -430,6 +432,7 @@ unlock_exit: mutex_unlock(&dev->lock); exit: + unlock_kernel(); dbg(2, "%s: leave, return value %d ", __func__, retval); return retval; diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 17e4eecaee7..47ce46bb5b0 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c @@ -77,7 +77,7 @@ static struct rio_usb_data rio_instance; static int open_rio(struct inode *inode, struct file *file) { struct rio_usb_data *rio = &rio_instance; - + lock_kernel(); mutex_lock(&(rio->lock)); if (rio->isopen || !rio->present) { @@ -91,6 +91,7 @@ static int open_rio(struct inode *inode, struct file *file) mutex_unlock(&(rio->lock)); dev_info(&rio->rio_dev->dev, "Rio opened.\n"); + unlock_kernel(); return 0; } diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index bb0b315b521..3991655f8f0 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) struct usb_interface *interface; int subminor = iminor(inode); - if (!(interface = usb_find_interface(&sisusb_driver, subminor))) + lock_kernel(); + if (!(interface = usb_find_interface(&sisusb_driver, subminor))) { + unlock_kernel(); return -ENODEV; + } - if (!(sisusb = usb_get_intfdata(interface))) + if (!(sisusb = usb_get_intfdata(interface))) { + unlock_kernel(); return -ENODEV; + } mutex_lock(&sisusb->lock); if (!sisusb->present || !sisusb->ready) { mutex_unlock(&sisusb->lock); + unlock_kernel(); return -ENODEV; } if (sisusb->isopen) { mutex_unlock(&sisusb->lock); + unlock_kernel(); return -EBUSY; } @@ -2439,11 +2446,13 @@ sisusb_open(struct inode *inode, struct file *file) if (sisusb_init_gfxdevice(sisusb, 0)) { mutex_unlock(&sisusb->lock); dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); + unlock_kernel(); return -EIO; } } else { mutex_unlock(&sisusb->lock); dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n"); + unlock_kernel(); return -EIO; } } @@ -2456,6 +2465,7 @@ sisusb_open(struct inode *inode, struct file *file) file->private_data = sisusb; mutex_unlock(&sisusb->lock); + unlock_kernel(); return 0; } diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 499d7508be9..90aede90553 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) struct usb_interface *interface; int subminor, r; + lock_kernel(); subminor = iminor(inode); interface = usb_find_interface(&lcd_driver, subminor); if (!interface) { + unlock_kernel(); err ("USBLCD: %s - error, can't find device for minor %d", __func__, subminor); return -ENODEV; @@ -87,6 +89,7 @@ static int lcd_open(struct inode *inode, struct file *file) dev = usb_get_intfdata(interface); if (!dev) { mutex_unlock(&open_disc_mutex); + unlock_kernel(); return -ENODEV; } @@ -98,11 +101,13 @@ static int lcd_open(struct inode *inode, struct file *file) r = usb_autopm_get_interface(interface); if (r < 0) { kref_put(&dev->kref, lcd_delete); + unlock_kernel(); return r; } /* save our object in the file's private structure */ file->private_data = dev; + unlock_kernel(); return 0; } diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c index 874c81bb27b..b787b25d4cc 100644 --- a/drivers/usb/misc/vstusb.c +++ b/drivers/usb/misc/vstusb.c @@ -27,6 +27,7 @@ #include <linux/slab.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/smp_lock.h> #include <linux/uaccess.h> #include <linux/usb.h> @@ -103,19 +104,23 @@ static int vstusb_open(struct inode *inode, struct file *file) struct vstusb_device *vstdev; struct usb_interface *interface; + lock_kernel(); interface = usb_find_interface(&vstusb_driver, iminor(inode)); if (!interface) { printk(KERN_ERR KBUILD_MODNAME ": %s - error, can't find device for minor %d\n", __func__, iminor(inode)); + unlock_kernel(); return -ENODEV; } vstdev = usb_get_intfdata(interface); - if (!vstdev) + if (!vstdev) { + unlock_kernel(); return -ENODEV; + } /* lock this device */ mutex_lock(&vstdev->lock); @@ -123,6 +128,7 @@ static int vstusb_open(struct inode *inode, struct file *file) /* can only open one time */ if ((!vstdev->present) || (vstdev->isopen)) { mutex_unlock(&vstdev->lock); + unlock_kernel(); return -EBUSY; } @@ -137,6 +143,7 @@ static int vstusb_open(struct inode *inode, struct file *file) dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__); mutex_unlock(&vstdev->lock); + unlock_kernel(); return 0; } |