[PATCH] x86: do_IRQ(): check irq number
authorAndrew Morton <[email protected]>
Wed, 28 Jun 2006 11:26:43 +0000 (04:26 -0700)
committerLinus Torvalds <[email protected]>
Wed, 28 Jun 2006 21:59:02 +0000 (14:59 -0700)
We recently changed x86 to handle more than 256 IRQs.  Add a check in do_IRQ()
just to make sure that nothing went wrong with that implementation.

[[email protected]: do x86_64 too]
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Rusty Russell <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Chris Wright <[email protected]>
Cc: "Protasevich, Natalie" <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/i386/kernel/irq.c
arch/x86_64/kernel/irq.c

index c703bc7b08800cc4f82298deb0817aa05178f4c7..9eec9435318ea4053f80a1f097edcff6bce0184a 100644 (file)
@@ -60,6 +60,12 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
        u32 *isp;
 #endif
 
+       if (unlikely((unsigned)irq >= NR_IRQS)) {
+               printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
+                                       __FUNCTION__, irq);
+               BUG();
+       }
+
        irq_enter();
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
        /* Debugging check for stack overflow: is there less than 1KB free? */
index 3be0a7e4bf08d1b0109c946d1470e0c0292bc214..bfa82f52a5cc5cb869f0c04905cd474ae54853b3 100644 (file)
@@ -118,6 +118,12 @@ asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
        /* high bit used in ret_from_ code  */
        unsigned irq = ~regs->orig_rax;
 
+       if (unlikely(irq >= NR_IRQS)) {
+               printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
+                                       __FUNCTION__, irq);
+               BUG();
+       }
+
        exit_idle();
        irq_enter();
 #ifdef CONFIG_DEBUG_STACKOVERFLOW