gpio: gpio-mxc: Fix race in installing chained IRQ handler
authorRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 16 Jun 2015 22:06:40 +0000 (23:06 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 18 Jun 2015 12:03:08 +0000 (14:03 +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().

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/E1Z4z0C-0002SX-Lj@rmk-PC.arm.linux.org.uk
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
drivers/gpio/gpio-mxc.c

index 9f7446a7ac64f0ee11a4fd675d87773d3b21f8e5..e4f42c95c32058129d7814c9a4640abc14ec8fd5 100644 (file)
@@ -437,14 +437,13 @@ static int mxc_gpio_probe(struct platform_device *pdev)
                irq_set_chained_handler(port->irq, mx2_gpio_irq_handler);
        } else {
                /* setup one handler for each entry */
-               irq_set_chained_handler(port->irq, mx3_gpio_irq_handler);
-               irq_set_handler_data(port->irq, port);
-               if (port->irq_high > 0) {
+               irq_set_chained_handler_and_data(port->irq,
+                                                mx3_gpio_irq_handler, port);
+               if (port->irq_high > 0)
                        /* setup handler for GPIO 16 to 31 */
-                       irq_set_chained_handler(port->irq_high,
-                                               mx3_gpio_irq_handler);
-                       irq_set_handler_data(port->irq_high, port);
-               }
+                       irq_set_chained_handler_and_data(port->irq_high,
+                                                        mx3_gpio_irq_handler,
+                                                        port);
        }
 
        err = bgpio_init(&port->bgc, &pdev->dev, 4,