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

regulator: keep index within bounds in da9034_get_ldo12_voltage()

If selector equals ARRAY_SIZE(da9034_ldo12_data), that is one too
large already.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>

authored by

Roel Kluin and committed by
Liam Girdwood
495353a3 ddec6810

+1 -1
+1 -1
drivers/regulator/da903x.c
··· 331 331 static int da9034_list_ldo12_voltage(struct regulator_dev *rdev, 332 332 unsigned selector) 333 333 { 334 - if (selector > ARRAY_SIZE(da9034_ldo12_data)) 334 + if (selector >= ARRAY_SIZE(da9034_ldo12_data)) 335 335 return -EINVAL; 336 336 return da9034_ldo12_data[selector] * 1000; 337 337 }