aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi.c')
-rw-r--r--drivers/scsi/scsi.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index d8afec8317cf..fb86479ffd4a 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -320,13 +320,14 @@ void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd,
320{ 320{
321 unsigned long flags; 321 unsigned long flags;
322 322
323 /* changing locks here, don't need to restore the irq state */
324 spin_lock_irqsave(&shost->free_list_lock, flags);
325 if (unlikely(list_empty(&shost->free_list))) { 323 if (unlikely(list_empty(&shost->free_list))) {
326 list_add(&cmd->list, &shost->free_list); 324 spin_lock_irqsave(&shost->free_list_lock, flags);
327 cmd = NULL; 325 if (list_empty(&shost->free_list)) {
326 list_add(&cmd->list, &shost->free_list);
327 cmd = NULL;
328 }
329 spin_unlock_irqrestore(&shost->free_list_lock, flags);
328 } 330 }
329 spin_unlock_irqrestore(&shost->free_list_lock, flags);
330 331
331 if (likely(cmd != NULL)) 332 if (likely(cmd != NULL))
332 scsi_pool_free_command(shost->cmd_pool, cmd); 333 scsi_pool_free_command(shost->cmd_pool, cmd);