abb->current_info_idx is used as array subscript to access volt_table,
thus the valid value range should be 0 ... desc->n_voltages - 1.
Signed-off-by: Axel Lin <[email protected]>
Acked-by: Nishanth Menon <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
return -EINVAL;
}
- if (abb->current_info_idx > (int)desc->n_voltages) {
- dev_err(dev, "%s: Corrupted data? idx(%d) > n_voltages(%d)\n",
+ if (abb->current_info_idx >= (int)desc->n_voltages) {
+ dev_err(dev, "%s: Corrupted data? idx(%d) >= n_voltages(%d)\n",
__func__, abb->current_info_idx, desc->n_voltages);
return -EINVAL;
}