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 f4716ad..acd8e9e 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;
 }