diff options
| author | Alan Stern <stern@rowland.harvard.edu> | 2010-05-07 10:41:10 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2010-05-07 17:33:52 -0400 |
| commit | fde4e2f73208b8f34f123791e39c0cb6bc74b32a (patch) | |
| tree | 0a0e85f2f83ddc8d7945c617709e582993438971 | |
| parent | fddb33f2e8872fa4857dd29f0b71a523c9ed5577 (diff) | |
HID: fix suspend crash by moving initializations earlier
Although the usbhid driver allocates its usbhid structure in the probe
routine, several critical fields in that structure don't get
initialized until usbhid_start(). However if report descriptor
parsing fails then usbhid_start() is never called. This leads to
problems during system suspend -- the system will freeze.
This patch (as1378) fixes the bug by moving the initialization
statements up into usbhid_probe().
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Bruno Prémont <bonbons@linux-vserver.org>
Tested-By: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
| -rw-r--r-- | drivers/hid/usbhid/hid-core.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 56d06cd8075b..7b85b696fdab 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
| @@ -999,13 +999,6 @@ static int usbhid_start(struct hid_device *hid) | |||
| 999 | } | 999 | } |
| 1000 | } | 1000 | } |
| 1001 | 1001 | ||
| 1002 | init_waitqueue_head(&usbhid->wait); | ||
| 1003 | INIT_WORK(&usbhid->reset_work, hid_reset); | ||
| 1004 | INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues); | ||
| 1005 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | ||
| 1006 | |||
| 1007 | spin_lock_init(&usbhid->lock); | ||
| 1008 | |||
| 1009 | usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); | 1002 | usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
| 1010 | if (!usbhid->urbctrl) { | 1003 | if (!usbhid->urbctrl) { |
| 1011 | ret = -ENOMEM; | 1004 | ret = -ENOMEM; |
| @@ -1179,6 +1172,12 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
| 1179 | usbhid->intf = intf; | 1172 | usbhid->intf = intf; |
| 1180 | usbhid->ifnum = interface->desc.bInterfaceNumber; | 1173 | usbhid->ifnum = interface->desc.bInterfaceNumber; |
| 1181 | 1174 | ||
| 1175 | init_waitqueue_head(&usbhid->wait); | ||
| 1176 | INIT_WORK(&usbhid->reset_work, hid_reset); | ||
| 1177 | INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues); | ||
| 1178 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | ||
| 1179 | spin_lock_init(&usbhid->lock); | ||
| 1180 | |||
| 1182 | ret = hid_add_device(hid); | 1181 | ret = hid_add_device(hid); |
| 1183 | if (ret) { | 1182 | if (ret) { |
| 1184 | if (ret != -ENODEV) | 1183 | if (ret != -ENODEV) |
