LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [2.6 patch] drivers/mfd/sm501.c: fix an off-by-one
@ 2007-03-19  9:25 Adrian Bunk
  0 siblings, 0 replies; only message in thread
From: Adrian Bunk @ 2007-03-19  9:25 UTC (permalink / raw)
  To: Ben Dooks, Vincent Sanders; +Cc: linux-kernel

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) {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-19  9:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-19  9:25 [2.6 patch] drivers/mfd/sm501.c: fix an off-by-one Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).