Skip to contentSkip to conversation

off by one bug

PATCH In review Dan Carpenter 2 participants 2 messages Jan 3, 2010

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

PATCH 1/1 off by one bug

If irq == WM8350_NUM_IRQ that would put us past the end of the array.

drivers/mfd/wm8350-irq.c +2 -2
@@ -434,7 +434,7 @@ int wm8350_register_irq(struct wm8350 *w
 			irq_handler_t handler, unsigned long flags,
 			const char *name, void *data)
 {
-	if (irq < 0 || irq > WM8350_NUM_IRQ || !handler)
+	if (irq < 0 || irq >= WM8350_NUM_IRQ || !handler)
 		return -EINVAL;
 
 	if (wm8350->irq[irq].handler)
@@ -453,7 +453,7 @@ EXPORT_SYMBOL_GPL(wm8350_register_irq);
 
 int wm8350_free_irq(struct wm8350 *wm8350, int irq)
 {
-	if (irq < 0 || irq > WM8350_NUM_IRQ)
+	if (irq < 0 || irq >= WM8350_NUM_IRQ)
 		return -EINVAL;
 
 	wm8350_mask_irq(wm8350, irq);
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Dan Carpenter

If irq == WM8350_NUM_IRQ that would put us past the end of the array.

but please take a look at the advice in Documentation/SubmittingPatches about picking a title for your patch, with the one you've got it's not even clear which subsystem you're talking about never mind which driver.