Skip to contentSkip to conversation

MIPS: OCTEON: Off by one in octeon_irq_gpio_map()

PATCH In review Dan Carpenter 2 participants 2 messages Jul 14, 2016

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

PATCH 1/1 MIPS: OCTEON: Off by one in octeon_irq_gpio_map()

It should be >= ARRAY_SIZE() instead of > ARRAY_SIZE().

Fixes 64b139f97c01 ('MIPS: OCTEON: irq: add CIB and other fixes')
arch/mips/cavium-octeon/octeon-irq.c +1 -1
index 368eb49..75a4add 100644
@@ -1260,7 +1260,7 @@ static int octeon_irq_gpio_map(struct irq_domain *d,
 
 	line = (hw + gpiod->base_hwirq) >> 6;
 	bit = (hw + gpiod->base_hwirq) & 63;
-	if (line > ARRAY_SIZE(octeon_irq_ciu_to_irq) ||
+	if (line >= ARRAY_SIZE(octeon_irq_ciu_to_irq) ||
 		octeon_irq_ciu_to_irq[line][bit] != 0)
 		return -EINVAL;
 
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

It should be >= ARRAY_SIZE() instead of > ARRAY_SIZE().

Fixes 64b139f97c01 ('MIPS: OCTEON: irq: add CIB and other fixes')

Good catch. This would probably only matter if a malformed device tree, or buggy device driver were encountered.

Quoted 15 lines
arch/mips/cavium-octeon/octeon-irq.c +1 -1
index 368eb49..75a4add 100644
@@ -1260,7 +1260,7 @@ static int octeon_irq_gpio_map(struct irq_domain *d,
 
  	line = (hw + gpiod->base_hwirq) >> 6;
  	bit = (hw + gpiod->base_hwirq) & 63;
-	if (line > ARRAY_SIZE(octeon_irq_ciu_to_irq) ||
+	if (line >= ARRAY_SIZE(octeon_irq_ciu_to_irq) ||
  		octeon_irq_ciu_to_irq[line][bit] != 0)
  		return -EINVAL;