m68k/psc: Fix race in installing chained IRQ handler
authorThomas Gleixner <tglx@linutronix.de>
Sun, 21 Jun 2015 19:00:30 +0000 (21:00 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 25 Jun 2015 09:57:54 +0000 (11:57 +0200)
Fix a race where a pending interrupt could be received and the handler
called before the handler's data has been setup, by converting to
irq_set_chained_handler_and_data().

Search and conversion was done with coccinelle:

@@
expression E1, E2, E3;
@@
(
-if (irq_set_chained_handler(E1, E3) != 0)
-   BUG();
|
-irq_set_chained_handler(E1, E3);
)
-irq_set_handler_data(E1, E2);
+irq_set_chained_handler_and_data(E1, E3, E2);

@@
expression E1, E2, E3;
@@
(
-if (irq_set_chained_handler(E1, E3) != 0)
-   BUG();
...
|
-irq_set_chained_handler(E1, E3);
...
)
-irq_set_handler_data(E1, E2);
+irq_set_chained_handler_and_data(E1, E3, E2);

Reported-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Joshua Thompson <funaho@jurai.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org
arch/m68k/mac/psc.c

index 835fa04511c85ad0d6e71ba8ee1f3a2dc26fcc1b..272dde481d170e815d740d0880ae613c3567cca8 100644 (file)
@@ -148,14 +148,10 @@ static void psc_irq(unsigned int irq, struct irq_desc *desc)
 
 void __init psc_register_interrupts(void)
 {
-       irq_set_chained_handler(IRQ_AUTO_3, psc_irq);
-       irq_set_handler_data(IRQ_AUTO_3, (void *)0x30);
-       irq_set_chained_handler(IRQ_AUTO_4, psc_irq);
-       irq_set_handler_data(IRQ_AUTO_4, (void *)0x40);
-       irq_set_chained_handler(IRQ_AUTO_5, psc_irq);
-       irq_set_handler_data(IRQ_AUTO_5, (void *)0x50);
-       irq_set_chained_handler(IRQ_AUTO_6, psc_irq);
-       irq_set_handler_data(IRQ_AUTO_6, (void *)0x60);
+       irq_set_chained_handler_and_data(IRQ_AUTO_3, psc_irq, (void *)0x30);
+       irq_set_chained_handler_and_data(IRQ_AUTO_4, psc_irq, (void *)0x40);
+       irq_set_chained_handler_and_data(IRQ_AUTO_5, psc_irq, (void *)0x50);
+       irq_set_chained_handler_and_data(IRQ_AUTO_6, psc_irq, (void *)0x60);
 }
 
 void psc_irq_enable(int irq) {