public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: [PATCH] max8998: fix off-by-one value range checking
Date: Wed, 04 Aug 2010 14:34:10 +0800	[thread overview]
Message-ID: <1280903650.8393.1.camel@mola> (raw)

In max8998_list_voltage() and max8998_set_voltage(),
we use ldo as array index of ldo_voltage_map.
Thus the valid range should be 0 .. ARRAY_SIZE(ldo_voltage_map)-1.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/max8998.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 03e55a1..ab67298 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -119,7 +119,7 @@ static int max8998_list_voltage(struct regulator_dev *rdev,
 	int ldo = max8998_get_ldo(rdev);
 	int val;
 
-	if (ldo > ARRAY_SIZE(ldo_voltage_map))
+	if (ldo >= ARRAY_SIZE(ldo_voltage_map))
 		return -EINVAL;
 
 	desc = ldo_voltage_map[ldo];
@@ -306,7 +306,7 @@ static int max8998_set_voltage(struct regulator_dev *rdev,
 	u8 val;
 	bool en_ramp = false;
 
-	if (ldo > ARRAY_SIZE(ldo_voltage_map))
+	if (ldo >= ARRAY_SIZE(ldo_voltage_map))
 		return -EINVAL;
 
 	desc = ldo_voltage_map[ldo];
-- 
1.5.4.3




             reply	other threads:[~2010-08-04  6:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-04  6:34 Axel Lin [this message]
2010-08-04  6:39 ` [PATCH] max8998: fix off-by-one value range checking Kyungmin Park
2010-08-04  7:50 ` Mark Brown
2010-08-04  8:08   ` Liam Girdwood
2010-08-05  1:43   ` Axel Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1280903650.8393.1.camel@mola \
    --to=axel.lin@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=m.szyprowski@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox