]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] fix scsi_setup_command_freelist failure path race
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Mon, 7 Jan 2008 22:59:05 +0000 (07:59 +0900)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Sat, 12 Jan 2008 00:29:18 +0000 (18:29 -0600)
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>
drivers/scsi/scsi.c

index ebc019380835d66063f990c1204df3c71b3aba39..54ff611b8677cb9fc414bb0fe2a22e860dfa997a 100644 (file)
@@ -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;
-
 }
 
 /**