{
        unsigned long flags;
 
-       /* changing locks here, don't need to restore the irq state */
-       spin_lock_irqsave(&shost->free_list_lock, flags);
        if (unlikely(list_empty(&shost->free_list))) {
-               list_add(&cmd->list, &shost->free_list);
-               cmd = NULL;
+               spin_lock_irqsave(&shost->free_list_lock, flags);
+               if (list_empty(&shost->free_list)) {
+                       list_add(&cmd->list, &shost->free_list);
+                       cmd = NULL;
+               }
+               spin_unlock_irqrestore(&shost->free_list_lock, flags);
        }
-       spin_unlock_irqrestore(&shost->free_list_lock, flags);
 
        if (likely(cmd != NULL))
                scsi_pool_free_command(shost->cmd_pool, cmd);