]> err.no Git - linux-2.6/commitdiff
mbcs: cdev lock_kernel() pushdown
authorJonathan Corbet <corbet@lwn.net>
Thu, 15 May 2008 17:24:23 +0000 (11:24 -0600)
committerJonathan Corbet <corbet@lwn.net>
Fri, 20 Jun 2008 20:05:48 +0000 (14:05 -0600)
This driver would appear to have no internal locking at all.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
drivers/char/mbcs.c

index f4716ad7348ae7185bdba2a35379b9a68fd37a63..acd8e9ed474ae74e6b53fd58539ec3efaf5f2b26 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/mm.h>
 #include <linux/uio.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -382,15 +383,19 @@ static int mbcs_open(struct inode *ip, struct file *fp)
        struct mbcs_soft *soft;
        int minor;
 
+       lock_kernel();
        minor = iminor(ip);
 
+       /* Nothing protects access to this list... */
        list_for_each_entry(soft, &soft_list, list) {
                if (soft->nasid == minor) {
                        fp->private_data = soft->cxdev;
+                       unlock_kernel();
                        return 0;
                }
        }
 
+       unlock_kernel();
        return -ENODEV;
 }