Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: gpio-keys - fix possible concurrent access in gpio_keys_irq_timer()

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>

authored by

Gatien Chevallier and committed by
Dmitry Torokhov
8f38219f f4a8f561

+2
+2
drivers/input/keyboard/gpio_keys.c
··· 449 449 release_timer); 450 450 struct input_dev *input = bdata->input; 451 451 452 + guard(spinlock_irqsave)(&bdata->lock); 453 + 452 454 if (bdata->key_pressed) { 453 455 input_report_key(input, *bdata->code, 0); 454 456 input_sync(input);