diff mbox series

scsi: qla2xxx: avoid possible garbage in qla8044_rd_reg_indirect()

Message ID 20240905050226.1959592-1-suhui@nfschina.com
State New
Headers show
Series scsi: qla2xxx: avoid possible garbage in qla8044_rd_reg_indirect() | expand

Commit Message

Su Hui Sept. 5, 2024, 5:02 a.m. UTC
Clang static checker (scan-build) warning:
drivers/scsi/qla2xxx/qla_nx2.c:line 2542, column 16:
Assigned value is garbage or undefined.

In qla8044_minidump_process_l1cache(), there is a garbage value
problem as follows.

'r_value' is garbage when qla8044_rd_reg_indirect() failed, so
'*data_ptr++ = r_value' assigned  garbage value to 'data_ptr'.
There are many others examples like this which using
qla8044_rd_reg_indirect() but not checking the return value.
When qla8044_rd_reg_indirect() failed, let 'r_value = 0' to avoid these
garbage values.

Fixes: 7ec0effd30bb ("[SCSI] qla2xxx: Add support for ISP8044.")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
 drivers/scsi/qla2xxx/qla_nx2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_nx2.c b/drivers/scsi/qla2xxx/qla_nx2.c
index 41ff6fbdb933..97fd1c7833b4 100644
--- a/drivers/scsi/qla2xxx/qla_nx2.c
+++ b/drivers/scsi/qla2xxx/qla_nx2.c
@@ -92,11 +92,13 @@  qla8044_rd_reg_indirect(scsi_qla_host_t *vha, uint32_t addr, uint32_t *data)
 	struct qla_hw_data *ha = vha->hw;
 
 	ret_val = qla8044_set_win_base(vha, addr);
-	if (!ret_val)
+	if (!ret_val) {
 		*data = qla8044_rd_reg(ha, QLA8044_WILDCARD);
-	else
+	} else {
+		*data = 0;
 		ql_log(ql_log_warn, vha, 0xb088,
 		    "%s: failed read of addr 0x%x!\n", __func__, addr);
+	}
 	return ret_val;
 }