Skip to contentSkip to conversation

intel_pmic_gpio: fix off-by-one value range checking

PATCH Applied Axel Lin 3 participants 3 messages Oct 8, 2010 – Oct 21, 2010 x86 platform drivers

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 intel_pmic_gpio: fix off-by-one value range checking

In pmic_irq_type(), we use gpio as array index for trigger, thus the valid value range for gpio should be 0 .. NUM_GPIO - 1.

---
 drivers/platform/x86/intel_pmic_gpio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/platform/x86/intel_pmic_gpio.c +1 -1
index c6e2a1d..f540ff9 100644
@@ -197,7 +197,7 @@ static int pmic_irq_type(unsigned irq, unsigned type)
 	u32 gpio = irq - pg->irq_base;
 	unsigned long flags;
 
-	if (gpio > pg->chip.ngpio)
+	if (gpio >= pg->chip.ngpio)
 		return -EINVAL;
 
 	spin_lock_irqsave(&pg->irqtypes.lock, flags);
Signature · 1 line
1.7.2
#1 lore raw
Quoted 4 lines · On Fri, 08 Oct 2010 17:54:31 +0800 Axel Lin <[email protected]> wrote:

In pmic_irq_type(), we use gpio as array index for trigger, thus the valid value range for gpio should be 0 .. NUM_GPIO - 1.

Agreed - thanks for spotting this.

Alan