[PATCH] USB: storage: Fix messed-up locking
This is patch as550 from Alan Stern. Apparently someone changed the SCSI core so that it no longer holds the host lock when doing a device or bus reset. usb-storage was updated at the time, but the change was done carelessly. Some of the code depends on that lock being held. This patch reintroduces the host lock where needed and tries to clarify the comments explaining why the lock is necessary. It also moves the code that clears the TIMED_OUT and ABORTING bitflags so that it executes as soon as the timed-out command has completed (and while the host lock is held). Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
b789696af8
commit
226173edae
@@ -392,11 +392,16 @@ SkipForAbort:
|
||||
/* If an abort request was received we need to signal that
|
||||
* the abort has finished. The proper test for this is
|
||||
* the TIMED_OUT flag, not srb->result == DID_ABORT, because
|
||||
* a timeout/abort request might be received after all the
|
||||
* USB processing was complete. */
|
||||
if (test_bit(US_FLIDX_TIMED_OUT, &us->flags))
|
||||
* the timeout might have occurred after the command had
|
||||
* already completed with a different result code. */
|
||||
if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
|
||||
complete(&(us->notify));
|
||||
|
||||
/* Allow USB transfers to resume */
|
||||
clear_bit(US_FLIDX_ABORTING, &us->flags);
|
||||
clear_bit(US_FLIDX_TIMED_OUT, &us->flags);
|
||||
}
|
||||
|
||||
/* finished working on this command */
|
||||
us->srb = NULL;
|
||||
scsi_unlock(host);
|
||||
|
Reference in New Issue
Block a user