Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1279191 > unrolled thread

[PATCH 4/4] cris: irq: stop loop from accessing array out of bound

Started byNiklas Cassel <nks@flawful.org>
First post2015-11-28 19:30 +0100
Last post2015-11-28 19:30 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 4/4] cris: irq: stop loop from accessing array out of bound Niklas Cassel <nks@flawful.org> - 2015-11-28 19:30 +0100

#1279191 — [PATCH 4/4] cris: irq: stop loop from accessing array out of bound

FromNiklas Cassel <nks@flawful.org>
Date2015-11-28 19:30 +0100
Subject[PATCH 4/4] cris: irq: stop loop from accessing array out of bound
Message-ID<qzSpY-3YM-33@gated-at.bofh.it>
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 <nks@flawful.org>
---
 arch/cris/arch-v32/kernel/irq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/cris/arch-v32/kernel/irq.c b/arch/cris/arch-v32/kernel/irq.c
index 6de8db6..b07da4b 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;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web