[PATCH 5/5] usb:Reduce scope of BKL in usb ioctl handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 4cf751ce24b4eab5d34622fb2cfdc33f77de9693 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver@xxxxxxxxxx>
Date: Wed, 13 Jan 2010 15:23:09 +0100
Subject: [PATCH 5/5] 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: Oliver Neukum <oliver@xxxxxxxxxx>
---
 drivers/usb/core/devio.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 35b6fb9..590b70e 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1703,9 +1703,12 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 
 	if (!(file->f_mode & FMODE_WRITE))
 		return -EPERM;
+
+	lock_kernel();
 	usb_lock_device(dev);
 	if (!connected(ps)) {
 		usb_unlock_device(dev);
+		unlock_kernel();
 		return -ENODEV;
 	}
 
@@ -1764,10 +1767,12 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		break;
 
 	case USBDEVFS_SUBMITURB:
+		unlock_kernel();
 		snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
 		ret = proc_submiturb(ps, p);
 		if (ret >= 0)
 			inode->i_mtime = CURRENT_TIME;
+		lock_kernel();
 		break;
 
 #ifdef CONFIG_COMPAT
@@ -1819,13 +1824,17 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		break;
 
 	case USBDEVFS_REAPURB:
+		unlock_kernel();
 		snoop(&dev->dev, "%s: REAPURB\n", __func__);
 		ret = proc_reapurb(ps, p);
+		lock_kernel();
 		break;
 
 	case USBDEVFS_REAPURBNDELAY:
+		unlock_kernel();
 		snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__);
 		ret = proc_reapurbnonblock(ps, p);
+		lock_kernel();
 		break;
 
 	case USBDEVFS_DISCSIGNAL:
@@ -1859,6 +1868,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		break;
 	}
 	usb_unlock_device(dev);
+	unlock_kernel();
 	if (ret >= 0)
 		inode->i_atime = CURRENT_TIME;
 	return ret;
@@ -1869,9 +1879,7 @@ static long usbdev_ioctl(struct file *file, unsigned int cmd,
 {
 	int ret;
 
-	lock_kernel();
 	ret = usbdev_do_ioctl(file, cmd, (void __user *)arg);
-	unlock_kernel();
 
 	return ret;
 }
@@ -1882,9 +1890,7 @@ static long usbdev_compat_ioctl(struct file *file, unsigned int cmd,
 {
 	int ret;
 
-	lock_kernel();
 	ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg));
-	unlock_kernel();
 
 	return ret;
 }
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux