Skip to content

Commit 8959b30

Browse files
committed
gpiolib: Fix irq_disable() semantics
The implementation if .irq_disable() which kicks in between the gpiolib and the driver is not properly mimicking the expected semantics of the irqchip core: the irqchip will call .irq_disable() if that exists, else it will call mask_irq() which first checks if .irq_mask() is defined before calling it. Since we are calling it unconditionally, we get this bug from drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c, as it only defines .irq_mask_ack and not .irq_mask: Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = (ptrval) (...) PC is at 0x0 LR is at gpiochip_irq_disable+0x20/0x30 Fix this by only calling .irq_mask() if it exists. Cc: Brian Masney <[email protected]> Cc: Hans Verkuil <[email protected]> Cc: [email protected] Reviewed-by: Bartosz Golaszewski <[email protected]> Fixes: 461c1a7 ("gpiolib: override irq_enable/disable") Signed-off-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f8788d8 commit 8959b30

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/gpio/gpiolib.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2306,9 +2306,16 @@ static void gpiochip_irq_disable(struct irq_data *d)
23062306
{
23072307
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
23082308

2309+
/*
2310+
* Since we override .irq_disable() we need to mimic the
2311+
* behaviour of __irq_disable() in irq/chip.c.
2312+
* First call .irq_disable() if it exists, else mimic the
2313+
* behaviour of mask_irq() which calls .irq_mask() if
2314+
* it exists.
2315+
*/
23092316
if (chip->irq.irq_disable)
23102317
chip->irq.irq_disable(d);
2311-
else
2318+
else if (chip->irq.chip->irq_mask)
23122319
chip->irq.chip->irq_mask(d);
23132320
gpiochip_disable_irq(chip, d->hwirq);
23142321
}

0 commit comments

Comments
 (0)