]> www.infradead.org Git - users/jedix/linux-maple.git/commit
HID: usbhid: fix inconsistent reset/resume/reset-resume behavior
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 23 Mar 2016 16:17:09 +0000 (12:17 -0400)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:46:42 +0000 (15:46 -0700)
commit648d23efb219596f676936a56cfaa7d992a990cf
treea2e5bb2ba4ed4f821155b9cafda3032496b695b4
parent92676cb0ed2d3014fd30b097c72aee6257a6d762
HID: usbhid: fix inconsistent reset/resume/reset-resume behavior

Orabug: 23331163

[ Upstream commit 972e6a993f278b416a8ee3ec65475724fc36feb2 ]

The usbhid driver has inconsistently duplicated code in its post-reset,
resume, and reset-resume pathways.

reset-resume doesn't check HID_STARTED before trying to
restart the I/O queues.

resume fails to clear the HID_SUSPENDED flag if HID_STARTED
isn't set.

resume calls usbhid_restart_queues() with usbhid->lock held
and the others call it without holding the lock.

The first item in particular causes a problem following a reset-resume
if the driver hasn't started up its I/O.  URB submission fails because
usbhid->urbin is NULL, and this triggers an unending reset-retry loop.

This patch fixes the problem by creating a new subroutine,
hid_restart_io(), to carry out all the common activities.  It also
adds some checks that were missing in the original code:

After a reset, there's no need to clear any halted endpoints.

After a resume, if a reset is pending there's no need to
restart any I/O until the reset is finished.

After a resume, if the interrupt-IN endpoint is halted there's
no need to submit the input URB until the halt has been
cleared.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Daniel Fraga <fragabr@gmail.com>
Tested-by: Daniel Fraga <fragabr@gmail.com>
CC: <stable@vger.kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 8db1fb6a6e0fdc6f6fbfabfc4c9c5a183a7527ac)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
drivers/hid/usbhid/hid-core.c