Commit 20613f24 authored by Jonathan Corbet's avatar Jonathan Corbet

usbcore: cdev lock_kernel() pushdown

usb_open() is protected by a down_read(&minor_rwsem), but I'm not sure I
trust it to protect everything including subsidiary open() functions.
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 1bcaa0bd
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/smp_lock.h>
#include <linux/usb.h> #include <linux/usb.h>
#include "usb.h" #include "usb.h"
...@@ -33,6 +34,7 @@ static int usb_open(struct inode * inode, struct file * file) ...@@ -33,6 +34,7 @@ static int usb_open(struct inode * inode, struct file * file)
int err = -ENODEV; int err = -ENODEV;
const struct file_operations *old_fops, *new_fops = NULL; const struct file_operations *old_fops, *new_fops = NULL;
lock_kernel();
down_read(&minor_rwsem); down_read(&minor_rwsem);
c = usb_minors[minor]; c = usb_minors[minor];
...@@ -51,6 +53,7 @@ static int usb_open(struct inode * inode, struct file * file) ...@@ -51,6 +53,7 @@ static int usb_open(struct inode * inode, struct file * file)
fops_put(old_fops); fops_put(old_fops);
done: done:
up_read(&minor_rwsem); up_read(&minor_rwsem);
unlock_kernel();
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment