HID: hiddev: protect against disconnect/NULL-dereference race
authorChris Ball <cjb@laptop.org>
Thu, 12 Aug 2010 23:07:40 +0000 (19:07 -0400)
committerJiri Kosina <jkosina@suse.cz>
Fri, 13 Aug 2010 09:19:24 +0000 (11:19 +0200)
commit7032269e87ade34cc12891675371fa2ac150a620
tree3f42a6e4449d00b8598c1796ee0a9523365e2dcb
parent1778ca298b06ec86af5fc9603447c379cbfb477b
HID: hiddev: protect against disconnect/NULL-dereference race

One of our users reports consistently hitting a NULL dereference that
resolves to the "hid_to_usb_dev(hid);" call in hiddev_ioctl(), when
disconnecting a Lego WeDo USB HID device from an OLPC XO running
Scratch software.  There's a FIXME comment and a guard against the
dereference, but that happens farther down the function than the
initial dereference does.

This patch moves the call to be below the guard, and the user reports
that it fixes the problem for him.  OLPC bug report:
http://dev.laptop.org/ticket/10174

Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/usbhid/hiddev.c