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

regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched

In the case of no id is matched, the variable i is equal to
ARRAY_SIZE(pm8607_regulator_info).

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>

authored by

Axel Lin and committed by
Liam Girdwood
99cd25ce 88585b83

+1 -1
+1 -1
drivers/regulator/88pm8607.c
··· 412 412 if (info->desc.id == res->start) 413 413 break; 414 414 } 415 - if ((i < 0) || (i > PM8607_ID_RG_MAX)) { 415 + if (i == ARRAY_SIZE(pm8607_regulator_info)) { 416 416 dev_err(&pdev->dev, "Failed to find regulator %llu\n", 417 417 (unsigned long long)res->start); 418 418 return -EINVAL;