[PATCH] scsi: be2iscsi:Fix the problem that the array may be out of bounds
From: Wen Zhiwei
Date: Sun Nov 21 2021 - 23:30:36 EST
By observing that the value of ulp_num may be
'BEISCSI_ULP_COUNT',this will cause the problem
of data out of bounds.Increase judgments to
eliminate risks.
Signed-off-by: Wen Zhiwei <wenzhiwei@xxxxxxxxxx>
---
drivers/scsi/be2iscsi/be_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index ab55681145f8..392a53184a00 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3947,7 +3947,8 @@ static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba)
for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++)
if (test_bit(ulp_num, &phba->fw_config.ulp_supported))
break;
-
+ if (ulp_num >= BEISCSI_ULP_COUNT)
+ return -ENOMEM;
ulp_icd_start = phba->fw_config.iscsi_icd_start[ulp_num];
arr_index = 0;
--
2.30.0