From 75e52ba125702608809726c1884046117631d0fe Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Thu, 22 Sep 2016 16:21:13 +0200 Subject: cris: irq: stop loop from accessing array out of bounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit array "interrupt" only has 32 or 64 elements, depending on machine. arch/cris/arch-v32/kernel/irq.c: In function ‘init_IRQ’: arch/cris/arch-v32/kernel/irq.c:475:3: warning: iteration 32u invokes undefined behavior [-Waggressive-loop-optimizations] set_exception_vector(i, interrupt[j]); ^ arch/cris/arch-v32/kernel/irq.c:474:2: note: containing loop for (i = FIRST_IRQ, j = 0; j < NBR_INTR_VECT; i++, j++) { ^ Signed-off-by: Niklas Cassel Signed-off-by: Jesper Nilsson --- arch/cris/arch-v32/kernel/irq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'arch/cris/arch-v32') diff --git a/arch/cris/arch-v32/kernel/irq.c b/arch/cris/arch-v32/kernel/irq.c index 6de8db67cb09..b07da4b695aa 100644 --- a/arch/cris/arch-v32/kernel/irq.c +++ b/arch/cris/arch-v32/kernel/irq.c @@ -471,9 +471,8 @@ init_IRQ(void) irq_set_default_host(domain); of_node_put(np); - for (i = FIRST_IRQ, j = 0; j < NBR_INTR_VECT; i++, j++) { + for (i = FIRST_IRQ, j = 0; j < NBR_INTR_VECT && j < MACH_IRQS; i++, j++) set_exception_vector(i, interrupt[j]); - } /* Mark Timer and IPI IRQs as CPU local */ irq_allocations[TIMER0_INTR_VECT - FIRST_IRQ].cpu = CPU_FIXED; -- cgit v1.2.3