gpio: Fix potential NULL handler data in chained irqchip handler
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Tue, 16 Sep 2014 13:23:15 +0000 (16:23 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 24 Sep 2014 07:47:20 +0000 (09:47 +0200)
There is possibility with misconfigured pins that interrupt occurs instantly
after setting irq_set_chained_handler() in gpiochip_set_chained_irqchip().
Now if handler gets called before irq_set_handler_data() the handler gets
NULL handler data.

Fix this by moving irq_set_handler_data() call before
irq_set_chained_handler() in gpiochip_set_chained_irqchip().

Cc: Stable <stable@vger.kernel.org> # 3.15+
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
drivers/gpio/gpiolib.c

index 3b54edf2befeffeae10e3c2eeea51486930197e3..c68d037de656d68b5808df8174de7bd57bac734e 100644 (file)
@@ -413,12 +413,12 @@ void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip,
                return;
        }
 
-       irq_set_chained_handler(parent_irq, parent_handler);
        /*
         * The parent irqchip is already using the chip_data for this
         * irqchip, so our callbacks simply use the handler_data.
         */
        irq_set_handler_data(parent_irq, gpiochip);
+       irq_set_chained_handler(parent_irq, parent_handler);
 }
 EXPORT_SYMBOL_GPL(gpiochip_set_chained_irqchip);