msm: camera: common: Add checking for regulator count

This change adds a checking for regulator count,
since the regulator array has fixed length, so
add a protection to avoid meeting index ouf of
bounds issue.

CRs-Fixed: 3250328
Change-Id: I123ffa993ee7b1deb06e3789fa4add6ca5ce6b9f
Signed-off-by: Depeng Shao <quic_depengs@quicinc.com>
This commit is contained in:
Depeng Shao
2022-07-22 10:14:01 +08:00
committed by Camera Software Integration
父節點 3dd3448144
當前提交 8f0ed15532

查看文件

@@ -1938,6 +1938,12 @@ static int cam_soc_util_get_dt_regulator_info
return 0;
}
if (soc_info->num_rgltr > CAM_SOC_MAX_REGULATOR) {
CAM_ERR(CAM_UTIL, "Invalid regulator count:%d",
soc_info->num_rgltr);
return -EINVAL;
}
for (i = 0; i < soc_info->num_rgltr; i++) {
rc = of_property_read_string_index(of_node,
"regulator-names", i, &soc_info->rgltr_name[i]);
@@ -2393,6 +2399,13 @@ static int cam_soc_util_regulator_enable_default(
int j = 0, rc = 0;
uint32_t num_rgltr = soc_info->num_rgltr;
if (num_rgltr > CAM_SOC_MAX_REGULATOR) {
CAM_ERR(CAM_UTIL,
"%s has invalid regulator number %d",
soc_info->dev_name, num_rgltr);
return -EINVAL;
}
for (j = 0; j < num_rgltr; j++) {
if (soc_info->rgltr_ctrl_support == true) {
rc = cam_soc_util_regulator_enable(soc_info->rgltr[j],