xhci: Remove TDs from TD lists when URBs are canceled.
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Tue, 2 Aug 2011 22:43:40 +0000 (15:43 -0700)
committerSarah Sharp <sarah.a.sharp@linux.intel.com>
Tue, 9 Aug 2011 21:49:25 +0000 (14:49 -0700)
commit585df1d90cb07a02ca6c7a7d339e56e46d50dafb
tree62c5f003587d22dd28e4ba27332314765a285975
parent522989a27c7badb608155b1f1dea3487ed431f74
xhci: Remove TDs from TD lists when URBs are canceled.

When a driver tries to cancel an URB, and the host controller is dying,
xhci_urb_dequeue will giveback the URB without removing the xhci_tds
that comprise that URB from the td_list or the cancelled_td_list.  This
can cause a race condition between the driver calling URB dequeue and
the stop endpoint command watchdog timer.

If the timer fires on a dying host, and a driver attempts to resubmit
while the watchdog timer has dropped the xhci->lock to giveback a
cancelled URB, URBs may be given back by the xhci_urb_dequeue() function.
At that point, the URB's priv pointer will be freed and set to NULL, but
the TDs will remain on the td_list.  This will cause an oops in
xhci_giveback_urb_in_irq() when the watchdog timer attempts to loop
through the endpoints' td_lists, giving back killed URBs.

Make sure that xhci_urb_dequeue() removes TDs from the TD lists and
canceled TD lists before it gives back the URB.

This patch should be backported to kernels as old as 2.6.36.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Andiry Xu <andiry.xu@amd.com>
Cc: stable@kernel.org
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c