Commit 26a77799 authored by Andrew Vasquez's avatar Andrew Vasquez Committed by Martin K. Petersen

scsi: qla2xxx: Correct error handling during initialization failures

Current code misses or fails to account for proper recovery during early
initialization failures:

 - Properly unwind allocations during probe() failures.

 - Protect against non-initialization memory allocations during
   unwinding.

 - Propagate error status during HW initialization.

 - Release SCSI host reference when memory allocations fail.
Signed-off-by: default avatarAndrew Vasquez <andrewv@marvell.com>
Signed-off-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent f0cecc1e
...@@ -2293,6 +2293,10 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha) ...@@ -2293,6 +2293,10 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
if (qla_ini_mode_enabled(vha) || qla_dual_mode_enabled(vha)) if (qla_ini_mode_enabled(vha) || qla_dual_mode_enabled(vha))
rval = qla2x00_init_rings(vha); rval = qla2x00_init_rings(vha);
/* No point in continuing if firmware initialization failed. */
if (rval != QLA_SUCCESS)
return rval;
ha->flags.chip_reset_done = 1; ha->flags.chip_reset_done = 1;
if (rval == QLA_SUCCESS && IS_QLA84XX(ha)) { if (rval == QLA_SUCCESS && IS_QLA84XX(ha)) {
......
...@@ -1809,8 +1809,13 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) ...@@ -1809,8 +1809,13 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
int que; int que;
struct qla_hw_data *ha = vha->hw; struct qla_hw_data *ha = vha->hw;
/* Continue only if initialization complete. */
if (!ha->base_qpair)
return;
__qla2x00_abort_all_cmds(ha->base_qpair, res); __qla2x00_abort_all_cmds(ha->base_qpair, res);
if (!ha->queue_pair_map)
return;
for (que = 0; que < ha->max_qpairs; que++) { for (que = 0; que < ha->max_qpairs; que++) {
if (!ha->queue_pair_map[que]) if (!ha->queue_pair_map[que])
continue; continue;
...@@ -3163,6 +3168,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -3163,6 +3168,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
ql_log(ql_log_fatal, base_vha, 0x003d, ql_log(ql_log_fatal, base_vha, 0x003d,
"Failed to allocate memory for queue pointers..." "Failed to allocate memory for queue pointers..."
"aborting.\n"); "aborting.\n");
ret = -ENODEV;
goto probe_failed; goto probe_failed;
} }
...@@ -4717,7 +4723,7 @@ qla2x00_mem_free(struct qla_hw_data *ha) ...@@ -4717,7 +4723,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
mempool_destroy(ha->ctx_mempool); mempool_destroy(ha->ctx_mempool);
ha->ctx_mempool = NULL; ha->ctx_mempool = NULL;
if (ql2xenabledif) { if (ql2xenabledif && ha->dif_bundl_pool) {
struct dsd_dma *dsd, *nxt; struct dsd_dma *dsd, *nxt;
list_for_each_entry_safe(dsd, nxt, &ha->pool.unusable.head, list_for_each_entry_safe(dsd, nxt, &ha->pool.unusable.head,
...@@ -4812,7 +4818,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, ...@@ -4812,7 +4818,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht,
if (!vha->gnl.l) { if (!vha->gnl.l) {
ql_log(ql_log_fatal, vha, 0xd04a, ql_log(ql_log_fatal, vha, 0xd04a,
"Alloc failed for name list.\n"); "Alloc failed for name list.\n");
scsi_remove_host(vha->host); scsi_host_put(vha->host);
return NULL; return NULL;
} }
...@@ -4824,7 +4830,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, ...@@ -4824,7 +4830,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht,
"Alloc failed for scan database.\n"); "Alloc failed for scan database.\n");
dma_free_coherent(&ha->pdev->dev, vha->gnl.size, dma_free_coherent(&ha->pdev->dev, vha->gnl.size,
vha->gnl.l, vha->gnl.ldma); vha->gnl.l, vha->gnl.ldma);
scsi_remove_host(vha->host); scsi_host_put(vha->host);
return NULL; return NULL;
} }
INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn); INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment