diff options
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_hwi.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c index f83bae48e6b7..512aed3ae4f1 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c | |||
@@ -2026,7 +2026,7 @@ static int bnx2fc_allocate_hash_table(struct bnx2fc_hba *hba) | |||
2026 | dma_segment_array = kzalloc(dma_segment_array_size, GFP_KERNEL); | 2026 | dma_segment_array = kzalloc(dma_segment_array_size, GFP_KERNEL); |
2027 | if (!dma_segment_array) { | 2027 | if (!dma_segment_array) { |
2028 | printk(KERN_ERR PFX "hash table pointers (dma) alloc failed\n"); | 2028 | printk(KERN_ERR PFX "hash table pointers (dma) alloc failed\n"); |
2029 | return -ENOMEM; | 2029 | goto cleanup_ht; |
2030 | } | 2030 | } |
2031 | 2031 | ||
2032 | for (i = 0; i < segment_count; ++i) { | 2032 | for (i = 0; i < segment_count; ++i) { |
@@ -2037,15 +2037,7 @@ static int bnx2fc_allocate_hash_table(struct bnx2fc_hba *hba) | |||
2037 | GFP_KERNEL); | 2037 | GFP_KERNEL); |
2038 | if (!hba->hash_tbl_segments[i]) { | 2038 | if (!hba->hash_tbl_segments[i]) { |
2039 | printk(KERN_ERR PFX "hash segment alloc failed\n"); | 2039 | printk(KERN_ERR PFX "hash segment alloc failed\n"); |
2040 | while (--i >= 0) { | 2040 | goto cleanup_dma; |
2041 | dma_free_coherent(&hba->pcidev->dev, | ||
2042 | BNX2FC_HASH_TBL_CHUNK_SIZE, | ||
2043 | hba->hash_tbl_segments[i], | ||
2044 | dma_segment_array[i]); | ||
2045 | hba->hash_tbl_segments[i] = NULL; | ||
2046 | } | ||
2047 | kfree(dma_segment_array); | ||
2048 | return -ENOMEM; | ||
2049 | } | 2041 | } |
2050 | memset(hba->hash_tbl_segments[i], 0, | 2042 | memset(hba->hash_tbl_segments[i], 0, |
2051 | BNX2FC_HASH_TBL_CHUNK_SIZE); | 2043 | BNX2FC_HASH_TBL_CHUNK_SIZE); |
@@ -2057,8 +2049,7 @@ static int bnx2fc_allocate_hash_table(struct bnx2fc_hba *hba) | |||
2057 | GFP_KERNEL); | 2049 | GFP_KERNEL); |
2058 | if (!hba->hash_tbl_pbl) { | 2050 | if (!hba->hash_tbl_pbl) { |
2059 | printk(KERN_ERR PFX "hash table pbl alloc failed\n"); | 2051 | printk(KERN_ERR PFX "hash table pbl alloc failed\n"); |
2060 | kfree(dma_segment_array); | 2052 | goto cleanup_dma; |
2061 | return -ENOMEM; | ||
2062 | } | 2053 | } |
2063 | memset(hba->hash_tbl_pbl, 0, PAGE_SIZE); | 2054 | memset(hba->hash_tbl_pbl, 0, PAGE_SIZE); |
2064 | 2055 | ||
@@ -2083,6 +2074,22 @@ static int bnx2fc_allocate_hash_table(struct bnx2fc_hba *hba) | |||
2083 | } | 2074 | } |
2084 | kfree(dma_segment_array); | 2075 | kfree(dma_segment_array); |
2085 | return 0; | 2076 | return 0; |
2077 | |||
2078 | cleanup_dma: | ||
2079 | for (i = 0; i < segment_count; ++i) { | ||
2080 | if (hba->hash_tbl_segments[i]) | ||
2081 | dma_free_coherent(&hba->pcidev->dev, | ||
2082 | BNX2FC_HASH_TBL_CHUNK_SIZE, | ||
2083 | hba->hash_tbl_segments[i], | ||
2084 | dma_segment_array[i]); | ||
2085 | } | ||
2086 | |||
2087 | kfree(dma_segment_array); | ||
2088 | |||
2089 | cleanup_ht: | ||
2090 | kfree(hba->hash_tbl_segments); | ||
2091 | hba->hash_tbl_segments = NULL; | ||
2092 | return -ENOMEM; | ||
2086 | } | 2093 | } |
2087 | 2094 | ||
2088 | /** | 2095 | /** |