aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc
diff options
context:
space:
mode:
authorMariusz Kozlowski <m.kozlowski@tuxland.pl>2007-01-01 19:07:32 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-01-06 10:05:18 -0500
commita96e0c7798057dd8055d0263c076fed975c10237 (patch)
tree29b0e003f6ef4347ea68dd4ec3a3507216ca8bd2 /drivers/scsi/lpfc
parent8e9d58e723e29e8b04c09bd9badd81c1d8232f5f (diff)
[SCSI] scsi: lpfc error path fix
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>
Diffstat (limited to 'drivers/scsi/lpfc')
-rw-r--r--drivers/scsi/lpfc/lpfc_mem.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
index 066292d3995a..ec3bbbde6f7a 100644
--- a/drivers/scsi/lpfc/lpfc_mem.c
+++ b/drivers/scsi/lpfc/lpfc_mem.c
@@ -56,6 +56,9 @@ lpfc_mem_alloc(struct lpfc_hba * phba)
56 56
57 pool->elements = kmalloc(sizeof(struct lpfc_dmabuf) * 57 pool->elements = kmalloc(sizeof(struct lpfc_dmabuf) *
58 LPFC_MBUF_POOL_SIZE, GFP_KERNEL); 58 LPFC_MBUF_POOL_SIZE, GFP_KERNEL);
59 if (!pool->elements)
60 goto fail_free_lpfc_mbuf_pool;
61
59 pool->max_count = 0; 62 pool->max_count = 0;
60 pool->current_count = 0; 63 pool->current_count = 0;
61 for ( i = 0; i < LPFC_MBUF_POOL_SIZE; i++) { 64 for ( i = 0; i < LPFC_MBUF_POOL_SIZE; i++) {
@@ -82,10 +85,11 @@ lpfc_mem_alloc(struct lpfc_hba * phba)
82 fail_free_mbox_pool: 85 fail_free_mbox_pool:
83 mempool_destroy(phba->mbox_mem_pool); 86 mempool_destroy(phba->mbox_mem_pool);
84 fail_free_mbuf_pool: 87 fail_free_mbuf_pool:
85 while (--i) 88 while (i--)
86 pci_pool_free(phba->lpfc_mbuf_pool, pool->elements[i].virt, 89 pci_pool_free(phba->lpfc_mbuf_pool, pool->elements[i].virt,
87 pool->elements[i].phys); 90 pool->elements[i].phys);
88 kfree(pool->elements); 91 kfree(pool->elements);
92 fail_free_lpfc_mbuf_pool:
89 pci_pool_destroy(phba->lpfc_mbuf_pool); 93 pci_pool_destroy(phba->lpfc_mbuf_pool);
90 fail_free_dma_buf_pool: 94 fail_free_dma_buf_pool:
91 pci_pool_destroy(phba->lpfc_scsi_dma_buf_pool); 95 pci_pool_destroy(phba->lpfc_scsi_dma_buf_pool);