Browse Source

msm: camera: cci: Number of CCI masters index validation

Number of CCI masters index validation to avoid
out of bound array indices access.

CRs-Fixed: 3381768
Change-Id: I14d4a111cc5c7dab17d071446cddccd7651389a3
Signed-off-by: Abhilash Mahapatra <[email protected]>
Abhilash Mahapatra 2 years ago
parent
commit
3114739e59
1 changed files with 8 additions and 1 deletions
  1. 8 1
      drivers/cam_sensor_module/cam_cci/cam_cci_core.c

+ 8 - 1
drivers/cam_sensor_module/cam_cci/cam_cci_core.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 // SPDX-License-Identifier: GPL-2.0-only
 /*
 /*
  * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
  */
 
 
 #include <linux/module.h>
 #include <linux/module.h>
@@ -1519,6 +1519,13 @@ static int32_t cam_cci_i2c_write(struct v4l2_subdev *sd,
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 	master = c_ctrl->cci_info->cci_i2c_master;
 	master = c_ctrl->cci_info->cci_i2c_master;
+	if (master >= MASTER_MAX || master < 0) {
+		CAM_ERR(CAM_CCI, "CCI%d_I2C_M%d Invalid I2C master addr",
+			cci_dev->soc_info.index,
+			master);
+		return -EINVAL;
+	}
+
 	CAM_DBG(CAM_CCI, "CCI%d_I2C_M%d_Q%d set param sid 0x%x retries %d id_map %d",
 	CAM_DBG(CAM_CCI, "CCI%d_I2C_M%d_Q%d set param sid 0x%x retries %d id_map %d",
 		cci_dev->soc_info.index, master, queue, c_ctrl->cci_info->sid, c_ctrl->cci_info->retries,
 		cci_dev->soc_info.index, master, queue, c_ctrl->cci_info->sid, c_ctrl->cci_info->retries,
 		c_ctrl->cci_info->id_map);
 		c_ctrl->cci_info->id_map);