Commit 01412a21 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

USB: Reduce scope of BKL in usb ioctl handling

This pushes BKL down in ioctl handling and drops it
for some important ioctls
Signed-off-by: default avatarOliver Neukum <oliver@neukum.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 86266452
...@@ -1719,9 +1719,12 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd, ...@@ -1719,9 +1719,12 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
if (!(file->f_mode & FMODE_WRITE)) if (!(file->f_mode & FMODE_WRITE))
return -EPERM; return -EPERM;
lock_kernel();
usb_lock_device(dev); usb_lock_device(dev);
if (!connected(ps)) { if (!connected(ps)) {
usb_unlock_device(dev); usb_unlock_device(dev);
unlock_kernel();
return -ENODEV; return -ENODEV;
} }
...@@ -1780,10 +1783,12 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd, ...@@ -1780,10 +1783,12 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
break; break;
case USBDEVFS_SUBMITURB: case USBDEVFS_SUBMITURB:
unlock_kernel();
snoop(&dev->dev, "%s: SUBMITURB\n", __func__); snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
ret = proc_submiturb(ps, p); ret = proc_submiturb(ps, p);
if (ret >= 0) if (ret >= 0)
inode->i_mtime = CURRENT_TIME; inode->i_mtime = CURRENT_TIME;
lock_kernel();
break; break;
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
...@@ -1835,13 +1840,17 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd, ...@@ -1835,13 +1840,17 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
break; break;
case USBDEVFS_REAPURB: case USBDEVFS_REAPURB:
unlock_kernel();
snoop(&dev->dev, "%s: REAPURB\n", __func__); snoop(&dev->dev, "%s: REAPURB\n", __func__);
ret = proc_reapurb(ps, p); ret = proc_reapurb(ps, p);
lock_kernel();
break; break;
case USBDEVFS_REAPURBNDELAY: case USBDEVFS_REAPURBNDELAY:
unlock_kernel();
snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__); snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__);
ret = proc_reapurbnonblock(ps, p); ret = proc_reapurbnonblock(ps, p);
lock_kernel();
break; break;
case USBDEVFS_DISCSIGNAL: case USBDEVFS_DISCSIGNAL:
...@@ -1875,6 +1884,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd, ...@@ -1875,6 +1884,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
break; break;
} }
usb_unlock_device(dev); usb_unlock_device(dev);
unlock_kernel();
if (ret >= 0) if (ret >= 0)
inode->i_atime = CURRENT_TIME; inode->i_atime = CURRENT_TIME;
return ret; return ret;
...@@ -1885,9 +1895,7 @@ static long usbdev_ioctl(struct file *file, unsigned int cmd, ...@@ -1885,9 +1895,7 @@ static long usbdev_ioctl(struct file *file, unsigned int cmd,
{ {
int ret; int ret;
lock_kernel();
ret = usbdev_do_ioctl(file, cmd, (void __user *)arg); ret = usbdev_do_ioctl(file, cmd, (void __user *)arg);
unlock_kernel();
return ret; return ret;
} }
...@@ -1898,9 +1906,7 @@ static long usbdev_compat_ioctl(struct file *file, unsigned int cmd, ...@@ -1898,9 +1906,7 @@ static long usbdev_compat_ioctl(struct file *file, unsigned int cmd,
{ {
int ret; int ret;
lock_kernel();
ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg)); ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg));
unlock_kernel();
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment