Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 196291
b: refs/heads/master
c: da54a0c
h: refs/heads/master
i:
  196289: d68d38b
  196287: 71541a3
v: v3
  • Loading branch information
Jiri Kosina committed Mar 30, 2010
1 parent f87f145 commit 090a2f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0a504541b3ba593535d70f3124546e5e471a175e
refs/heads/master: da54a0ced4502dc2a25df034f218463a2a50488d
19 changes: 17 additions & 2 deletions trunk/drivers/hid/usbhid/hiddev.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ static int hiddev_open(struct inode *inode, struct file *file)
struct hiddev_list *list;
int res, i;

/* See comment in hiddev_connect() for BKL explanation */
lock_kernel();
i = iminor(inode) - HIDDEV_MINOR_BASE;

Expand Down Expand Up @@ -894,8 +895,22 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
hiddev->hid = hid;
hiddev->exist = 1;

/* when lock_kernel() usage is fixed in usb_open(),
* we could also fix it here */
/*
* BKL here is used to avoid race after usb_register_dev().
* Once the device node has been created, open() could happen on it.
* The code below will then fail, as hiddev_table hasn't been
* updated.
*
* The obvious fix -- introducing mutex to guard hiddev_table[]
* doesn't work, as usb_open() and usb_register_dev() both take
* minor_rwsem, thus we'll have ABBA deadlock.
*
* Before BKL pushdown, usb_open() had been acquiring it in right
* order, so _open() was safe to use it to protect from this race.
* Now the order is different, but AB-BA deadlock still doesn't occur
* as BKL is dropped on schedule() (i.e. while sleeping on
* minor_rwsem). Fugly.
*/
lock_kernel();
retval = usb_register_dev(usbhid->intf, &hiddev_class);
if (retval) {
Expand Down

0 comments on commit 090a2f2

Please sign in to comment.