OSDN Git Service

usb: xhci: hold lock over xhci_abort_cmd_ring()
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 3 Jan 2017 16:28:49 +0000 (18:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2017 10:22:45 +0000 (11:22 +0100)
commitd88f0f6c5ba031c3cb4d0f46da7c5bb190c3984d
treeb584a262fb4ed740508a663862fab5dd92edcb94
parentf286c2513ba6eb7fb3dc5f8532fba0f7219d4dc1
usb: xhci: hold lock over xhci_abort_cmd_ring()

commit 4dea70778c0f48b4385c7720c363ec8d37a401b4 upstream.

In command timer function, xhci_handle_command_timeout(), xhci->lock
is unlocked before call into xhci_abort_cmd_ring(). This might cause
race between the timer function and the event handler.

The xhci_abort_cmd_ring() function sets the CMD_RING_ABORT bit in the
command register and polling it until the setting takes effect. A stop
command ring event might be handled between writing the abort bit and
polling for it. The event handler will restart the command ring, which
causes the failure of polling, and we ever believed that we failed to
stop it.

As a bonus, this also fixes some issues of calling functions without
locking in xhci_handle_command_timeout().

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c