Commit 166a7287 authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by James Bottomley

[SCSI] fix scsi_setup_command_freelist failure path race

Looks like that host_cmd_pool_mutex are necessary here.
Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent 210ba1d1
...@@ -319,17 +319,16 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost) ...@@ -319,17 +319,16 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost)
GFP_KERNEL | shost->cmd_pool->gfp_mask); GFP_KERNEL | shost->cmd_pool->gfp_mask);
if (!cmd) if (!cmd)
goto fail2; goto fail2;
list_add(&cmd->list, &shost->free_list); list_add(&cmd->list, &shost->free_list);
return 0; return 0;
fail2: fail2:
mutex_lock(&host_cmd_pool_mutex);
if (!--pool->users) if (!--pool->users)
kmem_cache_destroy(pool->slab); kmem_cache_destroy(pool->slab);
return -ENOMEM;
fail: fail:
mutex_unlock(&host_cmd_pool_mutex); mutex_unlock(&host_cmd_pool_mutex);
return -ENOMEM; return -ENOMEM;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment