USB: OHCI: Fix race between ED unlink and URB submission
authorAlan Stern <stern@rowland.harvard.edu>
Tue, 30 Jun 2015 15:25:54 +0000 (11:25 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 31 May 2018 23:30:16 +0000 (00:30 +0100)
commit0ebead18aa59b4095e919af108e40d4375e50c5f
treeda9f881b59c72b8a49d09b95231611f6563da291
parent3ea5e8ca5c4f15f1e8777dc12d345bab35746841
USB: OHCI: Fix race between ED unlink and URB submission

commit 7d8021c967648accd1b78e5e1ddaad655cd2c61f upstream.

This patch fixes a bug introduced by commit 977dcfdc6031 ("USB: OHCI:
don't lose track of EDs when a controller dies").  The commit changed
ed_state from ED_UNLINK to ED_IDLE too early, before finish_urb() had
been called.  The user-visible consequence is that the driver
occasionally crashes or locks up when an URB is submitted while
another URB for the same endpoint is being unlinked.

This patch moves the ED state change later, to the right place.  The
drawback is that now we may unnecessarily execute some instructions
multiple times when a controller dies.  Since controllers dying is an
exceptional occurrence, a little wasted time won't matter.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Heiko Przybyl <lil_tux@web.de>
Tested-by: Heiko Przybyl <lil_tux@web.de>
Fixes: 977dcfdc60311e7aa571cabf6f39c36dde13339e
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/host/ohci-q.c