public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Mark Brown <broonie@kernel.org>
Cc: "Andrii.Tseglytskyi" <andrii.tseglytskyi@ti.com>,
	Nishanth Menon <nm@ti.com>, Liam Girdwood <lrg@ti.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] regulator: ti-abb: Fix off-by-one valid range checking for abb->current_info_idx
Date: Sat, 04 May 2013 22:02:27 +0800	[thread overview]
Message-ID: <1367676147.5124.1.camel@phoenix> (raw)

abb->current_info_idx is used as array subscript to access volt_table,
thus the valid value range should be 0 ... desc->n_voltages - 1.

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

diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c
index c1870ea..870d209 100644
--- a/drivers/regulator/ti-abb-regulator.c
+++ b/drivers/regulator/ti-abb-regulator.c
@@ -387,8 +387,8 @@ static int ti_abb_get_voltage_sel(struct regulator_dev *rdev)
 		return -EINVAL;
 	}
 
-	if (abb->current_info_idx > (int)desc->n_voltages) {
-		dev_err(dev, "%s: Corrupted data? idx(%d) > n_voltages(%d)\n",
+	if (abb->current_info_idx >= (int)desc->n_voltages) {
+		dev_err(dev, "%s: Corrupted data? idx(%d) >= n_voltages(%d)\n",
 			__func__, abb->current_info_idx, desc->n_voltages);
 		return -EINVAL;
 	}
-- 
1.8.1.2




             reply	other threads:[~2013-05-04 14:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-04 14:02 Axel Lin [this message]
2013-05-04 15:19 ` [PATCH] regulator: ti-abb: Fix off-by-one valid range checking for abb->current_info_idx Nishanth Menon
2013-05-05 10:23 ` Mark Brown

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=1367676147.5124.1.camel@phoenix \
    --to=axel.lin@ingics.com \
    --cc=andrii.tseglytskyi@ti.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=nm@ti.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