From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org, Sean Young <sean@mess.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: Rik van Riel <riel@surriel.com>,
stable@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: [PATCH v2 5/6] media: rc: Fix race between bpf(BPG_PROG_ATTACH) and device unregister
Date: Tue, 1 Sep 2026 15:24:55 +0100 [thread overview]
Message-ID: <aa202bcf11d1564d72c617fb205cc29fe71afe76.1788272198.git.sean@mess.org> (raw)
In-Reply-To: <cover.1788272198.git.sean@mess.org>
Mark the device as unregistered before tearing down raw IR/bpf
state, so that racing bpf(BPF_PROG_{ATTACH,DETACH,QUERY}) calls
cannot slip in between ir_raw_event_unregister() completing and
dev->registered being cleared.
Fixes: dccc0c3ddf8f ("media: rc: fix race between unregister and urb/irq callbacks")
Signed-off-by: Sean Young <sean@mess.org>
Cc: stable@vger.kernel.org
---
drivers/media/rc/rc-main.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 3091bcd0e927..af7888fbfb91 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -2050,18 +2050,18 @@ void rc_unregister_device(struct rc_dev *dev)
if (!dev)
return;
+ mutex_lock(&dev->lock);
+ dev->registered = false;
+ if (dev->users && dev->close)
+ dev->close(dev);
+ mutex_unlock(&dev->lock);
+
if (dev->driver_type == RC_DRIVER_IR_RAW)
ir_raw_event_unregister(dev);
timer_delete_sync(&dev->timer_keyup);
timer_delete_sync(&dev->timer_repeat);
- mutex_lock(&dev->lock);
- if (dev->users && dev->close)
- dev->close(dev);
- dev->registered = false;
- mutex_unlock(&dev->lock);
-
rc_free_rx_device(dev);
/*
--
2.55.0
next prev parent reply other threads:[~2026-09-01 14:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1788272198.git.sean@mess.org>
2026-09-01 14:24 ` [PATCH v2 1/6] media: rc: Ensure registered is cleared in error path Sean Young
2026-09-01 14:24 ` [PATCH v2 2/6] media: rc: Ensure that rc_unregister_device() does not free input device Sean Young
2026-09-01 14:24 ` [PATCH v2 3/6] media: rc: Fix ABBA deadlock by making locks more fine grained Sean Young
2026-09-01 14:24 ` [PATCH v2 4/6] media: rc: Add missing locking for keymap Sean Young
2026-09-01 14:24 ` Sean Young [this message]
2026-09-01 14:24 ` [PATCH v2 6/6] media: rc: mce_kbd: Fix inconsistent locking of keylock 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=aa202bcf11d1564d72c617fb205cc29fe71afe76.1788272198.git.sean@mess.org \
--to=sean@mess.org \
--cc=bpf@vger.kernel.org \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=patrice.chotard@foss.st.com \
--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®