Skip to contentSkip to conversation

drivers/mfd/sm501.c: fix an off-by-one

PATCH New Adrian Bunk 1 participant 1 message Mar 19, 2007 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/mfd/sm501.c: fix an off-by-one

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

---

drivers/mfd/sm501.c renamed from drivers/mfd/sm501.c.old +1 -1
@@ -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) {