public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Ben Dooks <ben-linux@fluff.org>,
	Vincent Sanders <vince@arm.linux.org.uk>
Cc: linux-kernel@vger.kernel.org
Subject: [2.6 patch] drivers/mfd/sm501.c: fix an off-by-one
Date: Mon, 19 Mar 2007 10:25:41 +0100	[thread overview]
Message-ID: <20070319092541.GO752@stusta.de> (raw)

This patch fixes an off-by-one spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>

---
--- linux-2.6.21-rc3-mm2/drivers/mfd/sm501.c.old	2007-03-19 09:09:57.000000000 +0100
+++ linux-2.6.21-rc3-mm2/drivers/mfd/sm501.c	2007-03-19 09:15:12.000000000 +0100
@@ -314,17 +314,17 @@ int sm501_unit_power(struct device *dev,
 	mutex_lock(&sm->clock_lock);
 
 	mode = readl(sm->regs + SM501_POWER_MODE_CONTROL);
 	gate = readl(sm->regs + SM501_CURRENT_GATE);
 	clock = readl(sm->regs + SM501_CURRENT_CLOCK);
 
 	mode &= 3;		/* get current power mode */
 
-	if (unit > ARRAY_SIZE(sm->unit_power)) {
+	if (unit >= ARRAY_SIZE(sm->unit_power)) {
 		dev_err(dev, "%s: bad unit %d\n", __FUNCTION__, unit);
 		goto already;
 	}
 
 	dev_dbg(sm->dev, "%s: unit %d, cur %d, to %d\n", __FUNCTION__, unit,
 		sm->unit_power[unit], to);
 
 	if (to == 0 && sm->unit_power[unit] == 0) {


                 reply	other threads:[~2007-03-19  9:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20070319092541.GO752@stusta.de \
    --to=bunk@stusta.de \
    --cc=ben-linux@fluff.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vince@arm.linux.org.uk \
    /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