Charge:fix slab out of bounds risk

There is a risk if enum mmi_temp_zones value > num_temp_zones.
This will casue pointer point to a illegal memory address.

Change-Id: Ifa68a3b5325063d07a3ccddbb8636644a58fe1c6
Reviewed-on: https://gerrit.mot.com/1456222
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Hongshu Lou <louhs1@motorola.com>
Reviewed-by: Haijian Ma <mahj8@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
chailu1 2019-11-15 14:05:33 +08:00 • committed by Lu Chai
commit f30ab4d58b

View file

@ -2550,7 +2550,10 @@ static void mmi_basic_charge_sm(struct smb_mmi_charger *chip,
max_fv_mv = chip->base_fv_mv;
mmi_find_temp_zone(chip, prm, stat->batt_temp);
zone = &prm->temp_zones[prm->pres_temp_zone];
if (prm->pres_temp_zone >= chip->num_temp_zones)
zone = &prm->temp_zones[0];
else
zone = &prm->temp_zones[prm->pres_temp_zone];
if (!stat->charger_present && !is_wls_online(chip)) {
prm->pres_chrg_step = STEP_NONE;