drivers: thermal: Add conditional check before using buffer index
Add conditional check before accessing stats buffer index to avoid buffer overflow. Change-Id: I466a8649a624727c34fb27babacab704439a0f83 Signed-off-by: gnuthaki <quic_gnuthaki@quicinc.com>
This commit is contained in:
parent
30a002eefd
commit
690a5be816
@ -498,6 +498,12 @@ static int bcl_set_lbat(void *data, int low, int high)
|
||||
|
||||
mutex_lock(&bat_data->state_trans_lock);
|
||||
|
||||
bcl_lvl = bat_data->type - BCL_LVL0;
|
||||
if (bcl_lvl >= MAX_BCL_LVL_COUNT) {
|
||||
pr_err("Invalid sensor type level:%d\n", bat_data->type);
|
||||
mutex_unlock(&bat_data->state_trans_lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (high != BCL_TRIGGER_THRESHOLD &&
|
||||
bat_data->irq_num && bat_data->irq_enabled) {
|
||||
disable_irq_nosync(bat_data->irq_num);
|
||||
@ -508,7 +514,6 @@ static int bcl_set_lbat(void *data, int low, int high)
|
||||
bat_data->irq_num, low, high);
|
||||
} else if (high == BCL_TRIGGER_THRESHOLD &&
|
||||
bat_data->irq_num && !bat_data->irq_enabled) {
|
||||
bcl_lvl = bat_data->type - BCL_LVL0;
|
||||
bcl_update_clear_stats(&bcl_perph->stats[bcl_lvl]);
|
||||
enable_irq(bat_data->irq_num);
|
||||
enable_irq_wake(bat_data->irq_num);
|
||||
@ -591,6 +596,10 @@ static irqreturn_t bcl_handle_irq(int irq, void *data)
|
||||
bcl_read_vbat_tz(bcl_perph->param[BCL_VBAT_LVL0].tz_dev, &vbat);
|
||||
|
||||
bcl_lvl = perph_data->type - BCL_LVL0;
|
||||
if (bcl_lvl >= MAX_BCL_LVL_COUNT) {
|
||||
pr_err("Invalid sensor type level:%d\n", perph_data->type);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
if (irq_status & perph_data->status_bit_idx) {
|
||||
bcl_update_trigger_stats(&bcl_perph->stats[bcl_lvl], ibat, vbat);
|
||||
pr_debug(
|
||||
|
Loading…
Reference in New Issue
Block a user