Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpiolib: irq hooks: fix recursion in gpiochip_irq_unmask

irqchip shared with multiple gpiochips, leads to recursive call of
gpiochip_irq_mask/gpiochip_irq_unmask which was assigned to
rqchip->irq_mask/irqchip->irq_unmask, these happens becouse of
only irqchip->irq_enable == gpiochip_irq_enable is checked.

Let's add an additional check to make sure shared irqchip is detected
even if irqchip->irq_enable wasn't defined.

Fixes: a8173820f441 ("gpio: gpiolib: Allow GPIO IRQs to lazy disable")
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Link: https://lore.kernel.org/r/20201210070514.13238-1-nikita.shubin@maquefel.me
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Nikita Shubin and committed by
Linus Walleij
9d552219 e6071cad

+2 -1
+2 -1
drivers/gpio/gpiolib.c
··· 1419 1419 if (WARN_ON(gc->irq.irq_enable)) 1420 1420 return; 1421 1421 /* Check if the irqchip already has this hook... */ 1422 - if (irqchip->irq_enable == gpiochip_irq_enable) { 1422 + if (irqchip->irq_enable == gpiochip_irq_enable || 1423 + irqchip->irq_mask == gpiochip_irq_mask) { 1423 1424 /* 1424 1425 * ...and if so, give a gentle warning that this is bad 1425 1426 * practice.