[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1312445891.5448.1.camel@phoenix>
Date: Thu, 04 Aug 2011 16:18:11 +0800
From: Axel Lin <axel.lin@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Haojian Zhuang <haojian.zhuang@...vell.com>,
Liam Girdwood <lrg@...com>,
Mark Brown <broonie@...nsource.wolfsonmicro.com>
Subject: [PATCH] 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@...il.com>
---
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(-)
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 5dcdb0f..ca0d608 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -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;
--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists