pinctrl/mediatek: Fix race in installing chained IRQ handler

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 <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Julia Lawall <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: Hongzhou Yang <[email protected]>
Cc: Axel Lin <[email protected]>
Cc: Yingjoe Chen <[email protected]>
Cc: Maoguang Meng <[email protected]>
Cc: Colin Ian King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
This commit is contained in:
Thomas Gleixner 2015-06-21 20:16:09 +02:00
commit 1e10592136

View file

@ -1242,8 +1242,7 @@ int mtk_pctrl_init(struct platform_device *pdev,
set_irq_flags(virq, IRQF_VALID);
};
irq_set_chained_handler(irq, mtk_eint_irq_handler);
irq_set_handler_data(irq, pctl);
irq_set_chained_handler_and_data(irq, mtk_eint_irq_handler, pctl);
set_irq_flags(irq, IRQF_VALID);
return 0;