Fix USB HID initialization (#592785)

This commit is contained in:
Chuck Ebbert 2010-08-06 00:44:47 -04:00
parent 7512b7b33a
commit 02278bed64
3 changed files with 104 additions and 1 deletions

View File

@ -0,0 +1,40 @@
commit 57ab12e418ec4fe24c11788bb1bbdabb29d05679
Author: Jiri Kosina <jkosina at suse.cz>
Date: Wed Feb 17 14:25:01 2010 +0100
HID: usbhid: initialize interface pointers early enough
Move the initialization of USB interface pointers from _start()
over to _probe() callback, which is where it belongs.
This fixes case where interface is NULL when parsing of report
descriptor fails.
LKML-Reference: <20100213135720.603e5f64 at neptune.home>
Reported-by: Alan Stern <stern at rowland.harvard.edu>
Tested-by: Bruno Prémont <bonbons at linux-vserver.org>
Signed-off-by: Jiri Kosina <jkosina at suse.cz>
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 74bd3ca..ceaf4a1 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1005,9 +1005,6 @@ static int usbhid_start(struct hid_device *hid)
spin_lock_init(&usbhid->lock);
- usbhid->intf = intf;
- usbhid->ifnum = interface->desc.bInterfaceNumber;
-
usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL);
if (!usbhid->urbctrl) {
ret = -ENOMEM;
@@ -1178,6 +1175,8 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
hid->driver_data = usbhid;
usbhid->hid = hid;
+ usbhid->intf = intf;
+ usbhid->ifnum = interface->desc.bInterfaceNumber;
ret = hid_add_device(hid);
if (ret) {

View File

@ -0,0 +1,53 @@
commit fde4e2f73208b8f34f123791e39c0cb6bc74b32a
Author: Alan Stern <stern at rowland.harvard.edu>
Date: Fri May 7 10:41:10 2010 -0400
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 at rowland.harvard.edu>
Reported-by: Bruno Prémont <bonbons at linux-vserver.org>
Tested-By: Bruno Prémont <bonbons at linux-vserver.org>
Signed-off-by: Jiri Kosina <jkosina at suse.cz>
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 56d06cd..7b85b69 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)
}
}
- init_waitqueue_head(&usbhid->wait);
- INIT_WORK(&usbhid->reset_work, hid_reset);
- INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues);
- setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
-
- spin_lock_init(&usbhid->lock);
-
usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL);
if (!usbhid->urbctrl) {
ret = -ENOMEM;
@@ -1179,6 +1172,12 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
usbhid->intf = intf;
usbhid->ifnum = interface->desc.bInterfaceNumber;
+ init_waitqueue_head(&usbhid->wait);
+ INIT_WORK(&usbhid->reset_work, hid_reset);
+ INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues);
+ setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
+ spin_lock_init(&usbhid->lock);
+
ret = hid_add_device(hid);
if (ret) {
if (ret != -ENODEV)

View File

@ -47,7 +47,7 @@ Summary: The Linux kernel
# reset this by hand to 1 (or to 0 and then use rpmdev-bumpspec).
# scripts/rebase.sh should be made to do that for you, actually.
#
%global baserelease 156
%global baserelease 157
%global fedora_build %{baserelease}
# base_sublevel is the kernel version we're starting with and patching
@ -844,6 +844,9 @@ Patch14120: cifs-fix-dns-resolver.patch
# Red Hat Bugzilla #610911
Patch14130: kvm-mmu-fix-conflict-access-permissions-in-direct-sp.patch
Patch14140: hid-01-usbhid-initialize-interface-pointers-early-enough.patch
Patch14141: hid-02-fix-suspend-crash-by-moving-initializations-earlier.patch
# ==============================================================================
%endif
@ -1562,6 +1565,10 @@ ApplyPatch cifs-fix-dns-resolver.patch
ApplyPatch kvm-mmu-fix-conflict-access-permissions-in-direct-sp.patch
# RHBZ #592785
ApplyPatch hid-01-usbhid-initialize-interface-pointers-early-enough.patch
ApplyPatch hid-02-fix-suspend-crash-by-moving-initializations-earlier.patch
# END OF PATCH APPLICATIONS ====================================================
%endif
@ -2212,6 +2219,9 @@ fi
%kernel_variant_files -k vmlinux %{with_kdump} kdump
%changelog
* Fri Aug 08 2010 Chuck Ebbert <cebbert@redhat.com> 2.6.32.17-157
- Fix USB HID initialization (#592785)
* Mon Aug 02 2010 Chuck Ebbert <cebbert@redhat.com> 2.6.32.17-156
- Linux 2.6.32.17
- Drop the patches commented out for -rc1 except ssb_check_for_sprom.patch