Skip to contentSkip to conversation

gpio-timberdale: fix a potential wrapping issue

PATCH Applied Dan Carpenter 2 participants 3 messages Oct 11, 2012 – Oct 20, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio-timberdale: fix a potential wrapping issue

->last_ier is an unsigned long but the high bits can't be used int the original code because the shift wraps.

drivers/gpio/gpio-timberdale.c +2 -2
index 031c6ad..1a3e2b9 100644
@@ -116,7 +116,7 @@ static void timbgpio_irq_disable(struct irq_data *d)
 	unsigned long flags;
 
 	spin_lock_irqsave(&tgpio->lock, flags);
-	tgpio->last_ier &= ~(1 << offset);
+	tgpio->last_ier &= ~(1UL << offset);
 	iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
 	spin_unlock_irqrestore(&tgpio->lock, flags);
 }
@@ -128,7 +128,7 @@ static void timbgpio_irq_enable(struct irq_data *d)
 	unsigned long flags;
 
 	spin_lock_irqsave(&tgpio->lock, flags);
-	tgpio->last_ier |= 1 << offset;
+	tgpio->last_ier |= 1UL << offset;
 	iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
 	spin_unlock_irqrestore(&tgpio->lock, flags);
 }
#1 lore raw
Quoted 4 lines · Dan Carpenter

->last_ier is an unsigned long but the high bits can't be used int the original code because the shift wraps.

Applied, thanks!
Should we send this to stable? (I assume so ...)

Yours,
Linus Walleij

#2 lore raw
Quoted 9 lines · Linus Walleij
Quoted 4 lines · Dan Carpenter

->last_ier is an unsigned long but the high bits can't be used int the original code because the shift wraps.

Applied, thanks!
Should we send this to stable? (I assume so ...)

This was a static checker fix. I guess the answer would depend on if there are over 30 IRQs.

regards,
dan carpenter