Input: remove BKL, fix input_open_file() locking
Holding the BKL in input_open_file seems pointless because it does not protect against updates of input_table, and all open functions from the underlying drivers have proper mutex locking. This makes input_open_file take the input_mutex when accessing the table and no lock when calling into the lower function. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
77554b4d1f
commit
2f2177c8da
|
@ -1879,35 +1879,37 @@ static int input_open_file(struct inode *inode, struct file *file)
|
||||||
const struct file_operations *old_fops, *new_fops = NULL;
|
const struct file_operations *old_fops, *new_fops = NULL;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
lock_kernel();
|
err = mutex_lock_interruptible(&input_mutex);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
/* No load-on-demand here? */
|
/* No load-on-demand here? */
|
||||||
handler = input_table[iminor(inode) >> 5];
|
handler = input_table[iminor(inode) >> 5];
|
||||||
if (!handler || !(new_fops = fops_get(handler->fops))) {
|
if (handler)
|
||||||
err = -ENODEV;
|
new_fops = fops_get(handler->fops);
|
||||||
goto out;
|
|
||||||
}
|
mutex_unlock(&input_mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* That's _really_ odd. Usually NULL ->open means "nothing special",
|
* That's _really_ odd. Usually NULL ->open means "nothing special",
|
||||||
* not "no device". Oh, well...
|
* not "no device". Oh, well...
|
||||||
*/
|
*/
|
||||||
if (!new_fops->open) {
|
if (!new_fops || !new_fops->open) {
|
||||||
fops_put(new_fops);
|
fops_put(new_fops);
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_fops = file->f_op;
|
old_fops = file->f_op;
|
||||||
file->f_op = new_fops;
|
file->f_op = new_fops;
|
||||||
|
|
||||||
err = new_fops->open(inode, file);
|
err = new_fops->open(inode, file);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
fops_put(file->f_op);
|
fops_put(file->f_op);
|
||||||
file->f_op = fops_get(old_fops);
|
file->f_op = fops_get(old_fops);
|
||||||
}
|
}
|
||||||
fops_put(old_fops);
|
fops_put(old_fops);
|
||||||
out:
|
out:
|
||||||
unlock_kernel();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue