From: Nikita Shubin Date: Thu, 10 Dec 2020 07:05:14 +0000 (+0300) Subject: gpiolib: irq hooks: fix recursion in gpiochip_irq_unmask X-Git-Tag: v5.11-rc1~70^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d5522199505c761575c8ea31dcfd9a2a8d73614;p=thirdparty%2Flinux.git 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 Link: https://lore.kernel.org/r/20201210070514.13238-1-nikita.shubin@maquefel.me Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 589eceecf374f..5ce0c14c637b3 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1419,7 +1419,8 @@ static void gpiochip_set_irq_hooks(struct gpio_chip *gc) if (WARN_ON(gc->irq.irq_enable)) return; /* Check if the irqchip already has this hook... */ - if (irqchip->irq_enable == gpiochip_irq_enable) { + if (irqchip->irq_enable == gpiochip_irq_enable || + irqchip->irq_mask == gpiochip_irq_mask) { /* * ...and if so, give a gentle warning that this is bad * practice.