misc: cdev lock_kernel() pushdown
authorJonathan Corbet <corbet@lwn.net>
Thu, 15 May 2008 17:07:52 +0000 (11:07 -0600)
committerJonathan Corbet <corbet@lwn.net>
Fri, 20 Jun 2008 20:05:48 +0000 (14:05 -0600)
misc_open() looks fine, but who knows what all of the misc drivers are
doing in their open() functions?

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

index eaace0d..6e1563c 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/device.h>
 #include <linux/tty.h>
 #include <linux/kmod.h>
+#include <linux/smp_lock.h>
 
 /*
  * Head entry for the doubly linked miscdevice list
@@ -118,6 +119,7 @@ static int misc_open(struct inode * inode, struct file * file)
        int err = -ENODEV;
        const struct file_operations *old_fops, *new_fops = NULL;
        
+       lock_kernel();
        mutex_lock(&misc_mtx);
        
        list_for_each_entry(c, &misc_list, list) {
@@ -155,6 +157,7 @@ static int misc_open(struct inode * inode, struct file * file)
        fops_put(old_fops);
 fail:
        mutex_unlock(&misc_mtx);
+       unlock_kernel();
        return err;
 }