[PATCH] scsi: qla2xxx: avoid possible garbage in qla8044_rd_reg_indirect()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
 drivers/scsi/qla2xxx/qla_nx2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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;
 }
 
-- 
2.30.2





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux