Commit 99cd25ce authored by Axel Lin's avatar Axel Lin Committed by Liam Girdwood

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: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 88585b83
...@@ -412,7 +412,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev) ...@@ -412,7 +412,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
if (info->desc.id == res->start) if (info->desc.id == res->start)
break; break;
} }
if ((i < 0) || (i > PM8607_ID_RG_MAX)) { if (i == ARRAY_SIZE(pm8607_regulator_info)) {
dev_err(&pdev->dev, "Failed to find regulator %llu\n", dev_err(&pdev->dev, "Failed to find regulator %llu\n",
(unsigned long long)res->start); (unsigned long long)res->start);
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment