Skip to content

Commit

Permalink
ieee1394: sbp2: fix race condition in state change
Browse files Browse the repository at this point in the history
An intermediate transition from _RUNNING to _IN_SHUTDOWN could have been
missed by the former code.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
  • Loading branch information
Stefan Richter committed Nov 29, 2008
1 parent e47c1fe commit 2642b11
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/ieee1394/sbp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,12 +895,13 @@ static void sbp2_host_reset(struct hpsb_host *host)
return;

read_lock_irqsave(&sbp2_hi_logical_units_lock, flags);

list_for_each_entry(lu, &hi->logical_units, lu_list)
if (likely(atomic_read(&lu->state) !=
SBP2LU_STATE_IN_SHUTDOWN)) {
atomic_set(&lu->state, SBP2LU_STATE_IN_RESET);
if (atomic_cmpxchg(&lu->state,
SBP2LU_STATE_RUNNING, SBP2LU_STATE_IN_RESET)
== SBP2LU_STATE_RUNNING)
scsi_block_requests(lu->shost);
}

read_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags);
}

Expand Down

0 comments on commit 2642b11

Please sign in to comment.