Skip to content

Commit

Permalink
[SCSI] fix scsi_setup_command_freelist failure path race
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
FUJITA Tomonori authored and James Bottomley committed Jan 12, 2008
1 parent 210ba1d commit 166a728
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/scsi/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

/**
Expand Down

0 comments on commit 166a728

Please sign in to comment.