From: Martin Wilck <mwi...@suse.com>

Reset ha->rce, ha->eft and the respective dma fields if
the buffers aren't mapped for some reason. Also, treat
both failure cases (allocation and initialization failure)
equally. The next patch modifies the failure behavior
slightly again.

Fixes: ad0a0b01f088 "scsi: qla2xxx: Fix Firmware dump size for Extended
 login and Exchange Offload"
Fixes: a28d9e4ef997 "scsi: qla2xxx: Add support for multiple fwdump
 templates/segments"
Cc: Joe Carnuccio <joe.carnuc...@cavium.com>
Cc: Quinn Tran <qut...@marvell.com>
Cc: Himanshu Madhani <hmadh...@marvell.com>
Cc: Bart Van Assche <bvanass...@acm.org>
Signed-off-by: Martin Wilck <mwi...@suse.com>
---
 drivers/scsi/qla2xxx/qla_init.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 6dd68be..ca9c3f3 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -3063,6 +3063,8 @@ qla2x00_alloc_offload_mem(scsi_qla_host_t *vha)
                        ql_log(ql_log_warn, vha, 0x00be,
                            "Unable to allocate (%d KB) for FCE.\n",
                            FCE_SIZE / 1024);
+                       ha->fce_dma = 0;
+                       ha->fce = NULL;
                        goto try_eft;
                }
 
@@ -3111,9 +3113,12 @@ qla2x00_alloc_offload_mem(scsi_qla_host_t *vha)
 
                ha->eft_dma = tc_dma;
                ha->eft = tc;
+               return;
        }
 
 eft_err:
+       ha->eft = NULL;
+       ha->eft_dma = 0;
        return;
 }
 
@@ -3184,6 +3189,8 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
                        ql_log(ql_log_warn, vha, 0x00c1,
                            "Unable to allocate (%d KB) for EFT.\n",
                            EFT_SIZE / 1024);
+                       ha->eft = NULL;
+                       ha->eft_dma = 0;
                        goto allocate;
                }
 
@@ -3193,6 +3200,9 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
                            "Unable to initialize EFT (%d).\n", rval);
                        dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc,
                            tc_dma);
+                       ha->eft = NULL;
+                       ha->eft_dma = 0;
+                       goto allocate;
                }
                ql_dbg(ql_dbg_init, vha, 0x00c3,
                    "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024);
-- 
2.22.0

Reply via email to