diff mbox series

scsi: be2iscsi:Fix the problem that the array may be out of bounds

Message ID 20211120003233.69789-1-wenzhiwei@kylinos.cn (mailing list archive)
State Deferred
Headers show
Series scsi: be2iscsi:Fix the problem that the array may be out of bounds | expand

Commit Message

Wen Zhiwei Nov. 20, 2021, 12:32 a.m. UTC
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@kylinos.cn>
---
 drivers/scsi/be2iscsi/be_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

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;