]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: ipaq-micro-keys - fix potential deadlock
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 10 Jun 2026 06:05:42 +0000 (23:05 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 11 Jun 2026 20:52:09 +0000 (13:52 -0700)
The driver acquires the micro->lock spinlock in process context (in
micro_key_start() and micro_key_stop()) without disabling interrupts.
However, this lock is also acquired in hardirq context by the MFD core
rx handler (micro_rx_msg()) which is called from the serial ISR.

This can lead to a lock inversion deadlock if the interrupt fires on the
same CPU while the process context holds the lock.

Fix this by using guard(spinlock_irq) instead of guard(spinlock) in
micro_key_start() and micro_key_stop() to disable interrupts while
holding the lock.

Reported-by: sashiko-bot@kernel.org
Assisted-by: Antigravity:gemini-3.5-flash
Link: https://patch.msgid.link/aij-pfaKK-Nna7wf@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/ipaq-micro-keys.c

index 695ef3c2081a46ed62ef480945389380b755f496..3c7d6aa0fe292d3ff1c9789d445eebdf1ef597b4 100644 (file)
@@ -54,7 +54,7 @@ static void micro_key_receive(void *data, int len, unsigned char *msg)
 
 static void micro_key_start(struct ipaq_micro_keys *keys)
 {
-       guard(spinlock)(&keys->micro->lock);
+       guard(spinlock_irq)(&keys->micro->lock);
 
        keys->micro->key = micro_key_receive;
        keys->micro->key_data = keys;
@@ -62,7 +62,7 @@ static void micro_key_start(struct ipaq_micro_keys *keys)
 
 static void micro_key_stop(struct ipaq_micro_keys *keys)
 {
-       guard(spinlock)(&keys->micro->lock);
+       guard(spinlock_irq)(&keys->micro->lock);
 
        keys->micro->key = NULL;
        keys->micro->key_data = NULL;