Skip to content

Commit 8b81edd

Browse files
Marc Zyngierlinusw
authored andcommitted
gpio: pca953x: Survive spurious interrupts
The pca953x driver never checks the result of irq_find_mapping(), which returns 0 when no mapping is found. When a spurious interrupt is delivered (which can happen under obscure circumstances), the kernel explodes as it still tries to handle the error code as a real interrupt. Handle this particular case and warn on spurious interrupts. Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 47e538d commit 8b81edd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,21 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
824824
ret = pca953x_irq_pending(chip, pending);
825825
mutex_unlock(&chip->i2c_lock);
826826

827-
for_each_set_bit(level, pending, gc->ngpio)
828-
handle_nested_irq(irq_find_mapping(gc->irq.domain, level));
827+
if (ret) {
828+
ret = 0;
829+
830+
for_each_set_bit(level, pending, gc->ngpio) {
831+
int nested_irq = irq_find_mapping(gc->irq.domain, level);
832+
833+
if (unlikely(nested_irq <= 0)) {
834+
dev_warn_ratelimited(gc->parent, "unmapped interrupt %d\n", level);
835+
continue;
836+
}
837+
838+
handle_nested_irq(nested_irq);
839+
ret = 1;
840+
}
841+
}
829842

830843
return IRQ_RETVAL(ret);
831844
}

0 commit comments

Comments
 (0)