From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org, Sean Young <sean@mess.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Rik van Riel <riel@surriel.com>,
stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 06/17] media: rc: mce_kbd: Fix inconsistent locking of keylock
Date: Fri, 4 Sep 2026 14:07:34 +0100 [thread overview]
Message-ID: <1dd7a367cf7b1bd57fed39832b3926570d34a8a5.1788526920.git.sean@mess.org> (raw)
In-Reply-To: <cover.1788526920.git.sean@mess.org>
data->keylock is taken with spin_lock() in ir_mce_kbd_decode(), which
runs in the raw IR decode kthread with local interrupts enabled, but
with spin_lock_irqsave() in mce_kbd_rx_timeout(), the rx_timeout timer
callback, which runs in softirq context.
If the decode kthread is holding keylock via spin_lock() when a timer
interrupt fires on the same CPU and the softirq runs
mce_kbd_rx_timeout(), the softirq spins forever waiting for a lock
that only the now-preempted kthread can release, while the kthread
cannot run again until the softirq gives up the CPU. This deadlocks
the CPU.
Fixes: 53a62800efb2 ("media: rc: mce_kbd decoder: fix race condition")
Signed-off-by: Sean Young <sean@mess.org>
Cc: stable@vger.kernel.org
---
drivers/media/rc/ir-mce_kbd-decoder.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index bb2d7c37c263..d1c9263511b0 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -219,6 +219,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
struct mce_kbd_dec *data = &dev->raw->mce_kbd;
u32 scancode;
unsigned long delay;
+ unsigned long flags;
struct lirc_scancode lsc = {};
if (!is_timing_event(ev)) {
@@ -319,7 +320,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
scancode = data->body & 0xffffff;
dev_dbg(&dev->dev, "keyboard data 0x%08x\n",
data->body);
- spin_lock(&data->keylock);
+ spin_lock_irqsave(&data->keylock, flags);
if (scancode) {
delay = usecs_to_jiffies(dev->timeout) +
msecs_to_jiffies(100);
@@ -329,7 +330,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
}
/* Pass data to keyboard buffer parser */
ir_mce_kbd_process_keyboard_data(dev, scancode);
- spin_unlock(&data->keylock);
+ spin_unlock_irqrestore(&data->keylock, flags);
lsc.rc_proto = RC_PROTO_MCIR2_KBD;
break;
case MCIR2_MOUSE_NBITS:
--
2.55.0
next prev parent reply other threads:[~2026-09-04 13:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1788526920.git.sean@mess.org>
2026-09-04 13:07 ` [PATCH v3 01/17] media: rc: Ensure registered is cleared in error path Sean Young
2026-09-04 13:07 ` [PATCH v3 02/17] media: rc: Ensure that rc_unregister_device() does not free input device Sean Young
2026-09-04 13:07 ` [PATCH v3 03/17] media: rc: Fix ABBA deadlock by making locks more fine grained Sean Young
2026-09-04 13:07 ` [PATCH v3 04/17] media: rc: Add missing locking for keymap Sean Young
2026-09-04 13:07 ` [PATCH v3 05/17] media: rc: Fix race between bpf(BPG_PROG_ATTACH) and device unregister Sean Young
2026-09-04 13:07 ` Sean Young [this message]
2026-09-04 13:07 ` [PATCH v3 07/17] media: ene_ir: Ensure teardown is done in the correct order Sean Young
2026-09-04 13:07 ` [PATCH v3 08/17] media: rc: Use binary search for adding or updating a scancode Sean Young
2026-09-04 13:07 ` [PATCH v3 09/17] media: rc: imon: Bind both interfaces via usb_driver_claim_interface() Sean Young
2026-09-04 13:07 ` [PATCH v3 10/17] media: ir_toy: Remove unused struct field Sean Young
2026-09-04 13:07 ` [PATCH v3 11/17] media: nuvoton-cir: " Sean Young
2026-09-04 13:07 ` [PATCH v3 12/17] media: ite-cir: Removed " Sean Young
2026-09-04 13:07 ` [PATCH v3 13/17] media: fintek-cir: Remove unused fields Sean Young
2026-09-04 13:07 ` [PATCH v3 14/17] media: mceusb: Remove unused field Sean Young
2026-09-04 13:07 ` [PATCH v3 15/17] media: serial_ir: Fix race condition where timer can be re-armed Sean Young
2026-09-04 13:07 ` [PATCH v3 16/17] media: rc: After rc_unregister_device() timers " Sean Young
2026-09-04 13:07 ` [PATCH v3 17/17] media: rc: Validate carrier range in LIRC_SET_REC_CARRIER ioctl Sean Young
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1dd7a367cf7b1bd57fed39832b3926570d34a8a5.1788526920.git.sean@mess.org \
--to=sean@mess.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=riel@surriel.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®