From 7664e843e3226df7c15d0cc72e1cdcf9d00b67b8 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Tue, 16 Sep 2014 16:23:15 +0300 Subject: [PATCH] BACKPORT: gpio: Fix potential NULL handler data in chained irqchip handler 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 # 3.15+ Reviewed-by: Alexandre Courbot Signed-off-by: Jarkko Nikula (cherry picked from commit 324b0398781e7afb846378dd2d8a4374faaf236b) [abrestic: resolved merge conflict as was done upstream] Signed-off-by: Andrew Bresticker BUG=chrome-os-partner:30840 TEST=builds Change-Id: I9adcff381bf164082776aa7aed81f34f24dc4e38 Reviewed-on: https://chromium-review.googlesource.com/238917 Reviewed-by: Olof Johansson Commit-Queue: Andrew Bresticker Tested-by: Andrew Bresticker --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a4d531adc9fe..cdc2e6502f3d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1379,12 +1379,12 @@ void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, "chip that may sleep\n"); 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); } /* Set the parent IRQ for all affected IRQs */