]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCSI] scsi: lpfc error path fix
authorMariusz Kozlowski <m.kozlowski@tuxland.pl>
Tue, 2 Jan 2007 00:07:32 +0000 (01:07 +0100)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Sat, 6 Jan 2007 15:05:18 +0000 (09:05 -0600)
Add kmalloc failure check and fix the loop on error path. Without the
patch pool element at index [0] will not be freed.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Acked-by: James Smart <James.Smart@Emulex.Com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/lpfc/lpfc_mem.c

index 066292d3995a5b33eba898a34f76a1eab206c8c7..ec3bbbde6f7a397442eec29fbb477ca35a97f556 100644 (file)
@@ -56,6 +56,9 @@ lpfc_mem_alloc(struct lpfc_hba * phba)
 
        pool->elements = kmalloc(sizeof(struct lpfc_dmabuf) *
                                         LPFC_MBUF_POOL_SIZE, GFP_KERNEL);
+       if (!pool->elements)
+               goto fail_free_lpfc_mbuf_pool;
+
        pool->max_count = 0;
        pool->current_count = 0;
        for ( i = 0; i < LPFC_MBUF_POOL_SIZE; i++) {
@@ -82,10 +85,11 @@ lpfc_mem_alloc(struct lpfc_hba * phba)
  fail_free_mbox_pool:
        mempool_destroy(phba->mbox_mem_pool);
  fail_free_mbuf_pool:
-       while (--i)
+       while (i--)
                pci_pool_free(phba->lpfc_mbuf_pool, pool->elements[i].virt,
                                                 pool->elements[i].phys);
        kfree(pool->elements);
+ fail_free_lpfc_mbuf_pool:
        pci_pool_destroy(phba->lpfc_mbuf_pool);
  fail_free_dma_buf_pool:
        pci_pool_destroy(phba->lpfc_scsi_dma_buf_pool);