summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2008-01-07 23:59:05 +0100
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-12 01:29:18 +0100
commit166a72878f76e911f2d1ce4b2310d4403e94be11 (patch)
treeb076d9b97024a220437561d1a343e4a8f3630a63 /drivers/scsi/scsi.c
parent[SCSI] sr: update to follow tray status correctly (diff)
downloadlinux-166a72878f76e911f2d1ce4b2310d4403e94be11.tar.xz
linux-166a72878f76e911f2d1ce4b2310d4403e94be11.zip
[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>
Diffstat (limited to 'drivers/scsi/scsi.c')
-rw-r--r--drivers/scsi/scsi.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index ebc019380835..54ff611b8677 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -319,17 +319,16 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost)
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;
-
}
/**