diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 867e08433e4b07557e303033b2ba2cc940a54d12..433602aed4688e07167a074b27480b338b008aa6 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c @@ -265,9 +265,10 @@ static int hiddev_release(struct inode * inode, struct file * file) static int hiddev_open(struct inode *inode, struct file *file) { struct hiddev_list *list; - int res; + int res, i; - int i = iminor(inode) - HIDDEV_MINOR_BASE; + lock_kernel(); + i = iminor(inode) - HIDDEV_MINOR_BASE; if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i]) return -ENODEV; @@ -313,10 +314,12 @@ static int hiddev_open(struct inode *inode, struct file *file) usbhid_open(hid); } + unlock_kernel(); return 0; bail: file->private_data = NULL; kfree(list); + unlock_kernel(); return res; } diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c index 9b413a35e048e3e96790a98b810a4cb41d282ddd..0f505086774c73b45e94636fb0fc3b2182ccb49e 100644 --- a/drivers/media/video/dabusb.c +++ b/drivers/media/video/dabusb.c @@ -616,10 +616,12 @@ static int dabusb_open (struct inode *inode, struct file *file) { int devnum = iminor(inode); pdabusb_t s; + int r; if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB)) return -EIO; + lock_kernel(); s = &dabusb[devnum - DABUSB_MINOR]; dbg("dabusb_open"); @@ -634,6 +636,7 @@ static int dabusb_open (struct inode *inode, struct file *file) msleep_interruptible(500); if (signal_pending (current)) { + unlock_kernel(); return -EAGAIN; } mutex_lock(&s->mutex); @@ -641,6 +644,7 @@ static int dabusb_open (struct inode *inode, struct file *file) if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) { mutex_unlock(&s->mutex); dev_err(&s->usbdev->dev, "set_interface failed\n"); + unlock_kernel(); return -EINVAL; } s->opened = 1; @@ -649,7 +653,9 @@ static int dabusb_open (struct inode *inode, struct file *file) file->f_pos = 0; file->private_data = s; - return nonseekable_open(inode, file); + r = nonseekable_open(inode, file); + unlock_kernel(); + return r; } static int dabusb_release (struct inode *inode, struct file *file) diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c index 15aed87fe1bb5a0310d17684f5dcd6a47a4501f0..e2f82f0dbad87e8f12b6573e9b0dd3f4cb23670e 100644 --- a/drivers/staging/frontier/alphatrack.c +++ b/drivers/staging/frontier/alphatrack.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -325,6 +326,7 @@ static int usb_alphatrack_open(struct inode *inode, struct file *file) int retval = 0; struct usb_interface *interface; + lock_kernel(); nonseekable_open(inode, file); subminor = iminor(inode); @@ -394,6 +396,7 @@ static int usb_alphatrack_open(struct inode *inode, struct file *file) unlock_disconnect_exit: mutex_unlock(&disconnect_mutex); + unlock_kernel(); return retval; } diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c index ef8fcc8c67bd7db85cbc14607967a70e26487147..1d3f7dc90f4f2f2de4aee2ef06d9825effbfe17a 100644 --- a/drivers/staging/frontier/tranzport.c +++ b/drivers/staging/frontier/tranzport.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -343,6 +344,7 @@ static int usb_tranzport_open(struct inode *inode, struct file *file) int retval = 0; struct usb_interface *interface; + lock_kernel(); nonseekable_open(inode, file); subminor = iminor(inode); @@ -413,6 +415,7 @@ static int usb_tranzport_open(struct inode *inode, struct file *file) unlock_disconnect_exit: mutex_unlock(&disconnect_mutex); + unlock_kernel(); return retval; } diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 18aafcb08fc8be08536a4ff3caf75859bc003116..b75a3d8bb02f8f19a9faafc8e44eb71237dad865 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -516,6 +517,7 @@ static int wdm_open(struct inode *inode, struct file *file) struct usb_interface *intf; struct wdm_device *desc; + lock_kernel(); mutex_lock(&wdm_mutex); intf = usb_find_interface(&wdm_driver, minor); if (!intf) @@ -548,6 +550,7 @@ static int wdm_open(struct inode *inode, struct file *file) usb_autopm_put_interface(desc->intf); out: mutex_unlock(&wdm_mutex); + unlock_kernel(); return rv; } diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 93b5f85d7cebda8f1dcae4e248ab9f3f8adc2285..d53f9499f936a0e8a72828acac59b8e381695e43 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -56,6 +56,7 @@ #include #include #include +#include #undef DEBUG #include @@ -395,6 +396,7 @@ static int usblp_open(struct inode *inode, struct file *file) if (minor < 0) return -ENODEV; + lock_kernel(); mutex_lock (&usblp_mutex); retval = -ENODEV; @@ -434,6 +436,7 @@ static int usblp_open(struct inode *inode, struct file *file) } out: mutex_unlock (&usblp_mutex); + unlock_kernel(); return retval; } diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 8588c0937a89ea948dd8d839af7902e815e7d02e..426bfc72b9b4a0bbb8292c5f5be2356ffc90dcb4 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -113,6 +114,7 @@ static int usbtmc_open(struct inode *inode, struct file *filp) struct usbtmc_device_data *data; int retval = 0; + lock_kernel(); intf = usb_find_interface(&usbtmc_driver, iminor(inode)); if (!intf) { printk(KERN_ERR KBUILD_MODNAME @@ -128,6 +130,7 @@ static int usbtmc_open(struct inode *inode, struct file *filp) filp->private_data = data; exit: + unlock_kernel(); return retval; } diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index bfc6c2eea6471d87bdf77455e4e4d8ca3e160ca1..c3536f151f029674bfd49d33a093a30069ce8904 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c @@ -34,7 +34,6 @@ static int usb_open(struct inode * inode, struct file * file) int err = -ENODEV; const struct file_operations *old_fops, *new_fops = NULL; - lock_kernel(); down_read(&minor_rwsem); c = usb_minors[minor]; @@ -53,7 +52,6 @@ static int usb_open(struct inode * inode, struct file * file) fops_put(old_fops); done: up_read(&minor_rwsem); - unlock_kernel(); return err; } diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index e192e8f7c5601cdc7eda7c4ac72a1e425729a46b..dce4f7b69ac30e10a709fc76aa9849d005db9c39 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c @@ -96,6 +96,7 @@ #include #include #include +#include #include #include @@ -622,6 +623,7 @@ static int mdc800_device_open (struct inode* inode, struct file *file) int retval=0; int errn=0; + lock_kernel(); mutex_lock(&mdc800->io_lock); if (mdc800->state == NOT_CONNECTED) @@ -660,6 +662,7 @@ static int mdc800_device_open (struct inode* inode, struct file *file) error_out: mutex_unlock(&mdc800->io_lock); + unlock_kernel(); return errn; } diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 306e97825b36bbb2d9d6ae3885083189b5a5c765..ac8ad91c2dacd711385c5782263fd9df3c6629a3 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #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 f21bf5160f8321ffbd45d4b58c16496215b753c8..32c47fbee2882e391ef629055b7689a18ed8e211 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -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 a54c3cb804ce4a5e6cf315aa03508ac3231ee0c8..68df9ac76699438e49c19b42716f7e8c590c9db8 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -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 @@ static int idmouse_open(struct inode *inode, struct file *file) /* 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 5206423211fb218adb5babed450b28471625a30e..d3c8523638832f34c0d7fe5319232b1045df979d 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 7c0bd13eccb2cf0e0ee216a89a901108c274556a..8de32df5978a0756f7b63135e4b67f793259f4b4 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -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 3d4378fb441083c7032b0b6567efc482407dd76c..94e1b84134dd8ff2718c06d4f61a9a0357186c0d 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include @@ -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 @@ static int tower_open (struct inode *inode, struct file *file) 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 17e4eecaee734f12dccff1c54cee282ec12862f1..47ce46bb5b014a2866bccc3c6e75b5939b3b272f 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 bb0b315b521dd368b3dd2f798f9403f0f2330e43..3991655f8f09bf5612a2ca93fb11d73274a96d86 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 499d7508be9ac26db85965f9c854b41ea1d83311..90aede90553e112e69410a129e3bbbd2e2d29e6a 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 874c81bb27b9c415f6a349f777008f05d823b6fa..b787b25d4cc4980ecc8144f3a6258ad52abcd307 100644 --- a/drivers/usb/misc/vstusb.c +++ b/drivers/usb/misc/vstusb.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -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; } diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 61522787f39cdd4f2fbfd99d7467be4c62757031..e94176bfd2726f8a69e2a34120494762c93a9c19 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,7 @@ static int skel_open(struct inode *inode, struct file *file) int subminor; int retval = 0; + lock_kernel(); subminor = iminor(inode); interface = usb_find_interface(&skel_driver, subminor); @@ -135,6 +137,7 @@ static int skel_open(struct inode *inode, struct file *file) mutex_unlock(&dev->io_mutex); exit: + unlock_kernel(); return retval; }