[PATCH 1/2] scsi: message: fusion: fix array index check in mpt_sas_log_info()

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

 



"sas_loginfo.dw.originator" index for "originator_str" array currently
has an obscure check that looks like a typo because it does the opposite,
exiting the function if index is in the valid range. But if "bus_type"
not equals "SAS" and index is invalid, it will proceed to get the string,
even though it should exit anyway in the switch below.

Detected using the static analysis tool - Svace.

Fixes: 466544d8898f ("[SCSI] fusion SAS support (mptsas driver) updates")
Signed-off-by: Alexey Kodanev <aleksei.kodanev@xxxxxxxxxxx>
---
 drivers/message/fusion/mptbase.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 4bf669c55649..4f507fc2f02d 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -8076,8 +8076,8 @@ mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info, u8 cb_idx)
 	char *sub_code_desc = NULL;
 
 	sas_loginfo.loginfo = log_info;
-	if ((sas_loginfo.dw.bus_type != 3 /*SAS*/) &&
-	    (sas_loginfo.dw.originator < ARRAY_SIZE(originator_str)))
+	if ((sas_loginfo.dw.bus_type != 3 /*SAS*/) ||
+	    (sas_loginfo.dw.originator >= ARRAY_SIZE(originator_str)))
 		return;
 
 	originator_desc = originator_str[sas_loginfo.dw.originator];
-- 
2.25.1





[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