Skip to content

Commit 309c455

Browse files
author
Jonathan Corbet
committed
misc: cdev lock_kernel() pushdown
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>
1 parent 1f43964 commit 309c455

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎drivers/char/misc.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <linux/device.h>
5050
#include <linux/tty.h>
5151
#include <linux/kmod.h>
52+
#include <linux/smp_lock.h>
5253

5354
/*
5455
* Head entry for the doubly linked miscdevice list
@@ -118,6 +119,7 @@ static int misc_open(struct inode * inode, struct file * file)
118119
int err = -ENODEV;
119120
const struct file_operations *old_fops, *new_fops = NULL;
120121

122+
lock_kernel();
121123
mutex_lock(&misc_mtx);
122124

123125
list_for_each_entry(c, &misc_list, list) {
@@ -155,6 +157,7 @@ static int misc_open(struct inode * inode, struct file * file)
155157
fops_put(old_fops);
156158
fail:
157159
mutex_unlock(&misc_mtx);
160+
unlock_kernel();
158161
return err;
159162
}
160163

0 commit comments

Comments
 (0)