Skip to content

Commit

Permalink
MIPS/ralink: Fix race in installing chained IRQ handler
Browse files Browse the repository at this point in the history
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: Ralf Baechle <ralf@linux-mips.org>
Cc: Qais Yousef <qais.yousef@imgtec.com>
Cc: Andrew Bresticker <abrestic@chromium.org>
Cc: John Crispin <blogic@openwrt.org>
Cc: linux-mips@linux-mips.org
  • Loading branch information
Thomas Gleixner committed Jun 25, 2015
1 parent 746ad9a commit 5c1642e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions arch/mips/ralink/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ static int __init intc_of_init(struct device_node *node,

rt_intc_w32(INTC_INT_GLOBAL, INTC_REG_ENABLE);

irq_set_chained_handler(irq, ralink_intc_irq_handler);
irq_set_handler_data(irq, domain);
irq_set_chained_handler_and_data(irq, ralink_intc_irq_handler, domain);

/* tell the kernel which irq is used for performance monitoring */
rt_perfcount_irq = irq_create_mapping(domain, 9);
Expand Down

0 comments on commit 5c1642e

Please sign in to comment.