Skip to content

Commit

Permalink
usbcore: cdev lock_kernel() pushdown
Browse files Browse the repository at this point in the history
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: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Jonathan Corbet committed Jun 20, 2008
1 parent 1bcaa0b commit 20613f2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/usb/core/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/rwsem.h>
#include <linux/smp_lock.h>
#include <linux/usb.h>

#include "usb.h"
Expand All @@ -33,6 +34,7 @@ static int usb_open(struct inode * inode, struct file * file)
int err = -ENODEV;
const struct file_operations *old_fops, *new_fops = NULL;

lock_kernel();
down_read(&minor_rwsem);
c = usb_minors[minor];

Expand All @@ -51,6 +53,7 @@ static int usb_open(struct inode * inode, struct file * file)
fops_put(old_fops);
done:
up_read(&minor_rwsem);
unlock_kernel();
return err;
}

Expand Down

0 comments on commit 20613f2

Please sign in to comment.