[SCSI] fix scsi_setup_command_freelist failure path race
Looks like that host_cmd_pool_mutex are necessary here.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index ebc0193..54ff611 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -319,17 +319,16 @@
GFP_KERNEL | shost->cmd_pool->gfp_mask);
if (!cmd)
goto fail2;
- list_add(&cmd->list, &shost->free_list);
+ list_add(&cmd->list, &shost->free_list);
return 0;
fail2:
+ mutex_lock(&host_cmd_pool_mutex);
if (!--pool->users)
kmem_cache_destroy(pool->slab);
- return -ENOMEM;
fail:
mutex_unlock(&host_cmd_pool_mutex);
return -ENOMEM;
-
}
/**