linux/drivers/hid/usbhid
Oliver Neukum e43bd67d72 HID: fix race between usb_register_dev() and hiddev_open()
upon further thought this code is still racy.

	retval = usb_register_dev(usbhid->intf, &hiddev_class);

here you open a window during which open can happen

	if (retval) {
		err_hid("Not able to get a minor for this device.");
		hid->hiddev = NULL;
		kfree(hiddev);
		return -1;
	} else {
		hid->minor = usbhid->intf->minor;
		hiddev_table[usbhid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;

and will fail because hiddev_table hasn't been updated

The obvious fix of using a mutex to guard hiddev_table doesn't work because
usb_open() and usb_register_dev() take minor_rwsem and we'd have an AB-BA
deadlock. We need a lock usb_open() also takes in the right order and that leaves
only one option, BKL. I don't like it but I see no alternative.

Once the usb_open() implements something better than lock_kernel(), we could also
do so.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-30 15:12:52 +02:00
..
hid-core.c HID: bring back possibility to specify vid/pid ignore on module load 2009-03-30 15:12:52 +02:00
hid-pidff.c HID: fix a lockup regression when using force feedback on a PID device 2008-10-14 23:51:02 +02:00
hid-quirks.c HID: add proper support for pensketch 12x9 tablet 2009-01-04 01:01:43 +01:00
hiddev.c HID: fix race between usb_register_dev() and hiddev_open() 2009-03-30 15:12:52 +02:00
Kconfig HID: make boot protocol drivers depend on EMBEDDED 2009-01-04 01:00:53 +01:00
Makefile HID: remove hid-ff 2008-10-14 23:51:01 +02:00
usbhid.h HID: move usbhid flags to usbhid.h 2009-01-04 01:00:51 +01:00
usbkbd.c HID: remove warn() macro from usb hid drivers 2008-10-14 23:51:03 +02:00
usbmouse.c HID: remove info() macro from usb HID drivers 2008-10-14 23:51:03 +02:00