Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: ti-abb: Fix off-by-one valid range checking for abb->current_info_idx

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 <axel.lin@ingics.com>
Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Axel Lin and committed by
Mark Brown
f5cd8de2 40b1936e

+2 -2
+2 -2
drivers/regulator/ti-abb-regulator.c
··· 387 387 return -EINVAL; 388 388 } 389 389 390 - if (abb->current_info_idx > (int)desc->n_voltages) { 391 - dev_err(dev, "%s: Corrupted data? idx(%d) > n_voltages(%d)\n", 390 + if (abb->current_info_idx >= (int)desc->n_voltages) { 391 + dev_err(dev, "%s: Corrupted data? idx(%d) >= n_voltages(%d)\n", 392 392 __func__, abb->current_info_idx, desc->n_voltages); 393 393 return -EINVAL; 394 394 }