regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched
PATCH 1/1 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).
---
I think compare variable i with ARRAY_SIZE(pm8607_regulator_info) here is slightly better in readability than compare with PM8607_ID_RG_MAX.
Axel
drivers/regulator/88pm8607.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/88pm8607.c +1 -1
@@ -413,7 +413,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)if (info->desc.id == res->start)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" , (unsigned long long )res->start);return -EINVAL ;
Signature · 1 line
1.7.4.1
Quoted 4 lines · Axel Lin
In the case of no id is matched, the variable i is equal to
ARRAY_SIZE(pm8607_regulator_info).Signed-off-by Axel Lin <[email protected]>
Quoted 2 lines
I think compare variable i with
ARRAY_SIZE(pm8607_regulator_info)here is slightly better in readability than compare withPM8607_ID_RG_MAX.
It should be more robust I guess.
Liam Girdwood
AppliedQuoted 9 lines · Axel Lin
In the case of no id is matched, the variable i is equal to
ARRAY_SIZE(pm8607_regulator_info).Signed-off-by Axel Lin <[email protected]>---
I think compare variable i withARRAY_SIZE(pm8607_regulator_info)here is slightly better in readability than compare withPM8607_ID_RG_MAX.
Axel
Applied.
Thanks
Liam