]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: gpio-keys - fix possible concurrent access in gpio_keys_irq_timer()
authorGatien Chevallier <gatien.chevallier@foss.st.com>
Fri, 30 May 2025 23:09:23 +0000 (16:09 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 30 May 2025 23:15:42 +0000 (16:15 -0700)
gpio_keys_irq_isr() and gpio_keys_irq_timer() access the same resources.
There could be a concurrent access if a GPIO interrupt occurs in parallel
of a HR timer interrupt.

Guard back those resources with a spinlock.

Fixes: 019002f20cb5 ("Input: gpio-keys - use hrtimer for release timer")
Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
Link: https://lore.kernel.org/r/20250528-gpio_keys_preempt_rt-v2-2-3fc55a9c3619@foss.st.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/gpio_keys.c

index d884538107c9654d21e37fa20e0b3b6cd9a25ee4..f9db86da0818b24d3b6611b4d4e23c96846dbf18 100644 (file)
@@ -449,6 +449,8 @@ static enum hrtimer_restart gpio_keys_irq_timer(struct hrtimer *t)
                                                      release_timer);
        struct input_dev *input = bdata->input;
 
+       guard(spinlock_irqsave)(&bdata->lock);
+
        if (bdata->key_pressed) {
                input_report_key(input, *bdata->code, 0);
                input_sync(input);