All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpiolib: irq hooks: fix recursion in gpiochip_irq_unmask
@ 2020-12-10  7:05 Nikita Shubin
  2020-12-11 23:26 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Nikita Shubin @ 2020-12-10  7:05 UTC (permalink / raw)
  Cc: Nikita Shubin, Linus Walleij, Bartosz Golaszewski, Maulik Shah,
	linux-gpio, linux-kernel

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>
---
 drivers/gpio/gpiolib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 589eceecf374..5ce0c14c637b 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.
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpiolib: irq hooks: fix recursion in gpiochip_irq_unmask
  2020-12-10  7:05 [PATCH] gpiolib: irq hooks: fix recursion in gpiochip_irq_unmask Nikita Shubin
@ 2020-12-11 23:26 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2020-12-11 23:26 UTC (permalink / raw)
  To: Nikita Shubin
  Cc: Bartosz Golaszewski, Maulik Shah, open list:GPIO SUBSYSTEM, linux-kernel

On Thu, Dec 10, 2020 at 8:06 AM Nikita Shubin <nikita.shubin@maquefel.me> wrote:

> 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>

Good catch!
Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-11 23:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10  7:05 [PATCH] gpiolib: irq hooks: fix recursion in gpiochip_irq_unmask Nikita Shubin
2020-12-11 23:26 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.