From: Karlos Abel <kabel@voidship.net>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
sashiko-bot@kernel.org
Subject: [PATCH v3 1/2] Input: discard pre-registration events before attaching handlers
Date: Sat, 10 Oct 2026 18:58:07 -0400 [thread overview]
Message-ID: <20261010225808.36404-2-kabel@voidship.net> (raw)
In-Reply-To: <20261010225808.36404-1-kabel@voidship.net>
input_event() permits drivers to seed switch and absolute-axis state
before registration without delivering those events to input handlers.
After event-buffer allocation moved to input_allocate_device(), such
initialization events can remain queued across input_register_device()
when the buffer does not need resizing.
A later injected LED event followed by SYN_REPORT then delivers the old
switch event to newly attached handlers. This was observed with the
initial SW_RFKILL_ALL event from thinkpad_acpi on a ThinkPad T14 Gen 6:
an LED update replayed the initial radio-switch event after registration.
Registration can also leave a pre-registration timestamp attached to the
first real event packet, including when the event buffer is resized.
Clear the pending event count and monotonic timestamp under event_lock
before attaching handlers. Keep the switch and absolute-axis state that
was seeded by those events. Resetting the monotonic timestamp follows the
existing flush path and lets the next packet obtain a fresh timestamp.
Fixes: 0cd587735205 ("Input: preallocate memory to hold event values")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Karlos Abel <kabel@voidship.net>
---
drivers/input/input.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 01c91fec9..a0ba3eb23 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -25,6 +25,7 @@
#include <linux/device.h>
#include <linux/kstrtox.h>
#include <linux/mutex.h>
+#include <linux/spinlock.h>
#include <linux/rcupdate.h>
#include "input-compat.h"
#include "input-core-private.h"
@@ -2445,6 +2446,12 @@ int input_register_device(struct input_dev *dev)
error = -EINTR;
scoped_cond_guard(mutex_intr, goto err_device_del, &input_mutex) {
+ /* Keep seeded state, but do not replay pre-registration events. */
+ spin_lock_irq(&dev->event_lock);
+ dev->num_vals = 0;
+ dev->timestamp[INPUT_CLK_MONO] = ktime_set(0, 0);
+ spin_unlock_irq(&dev->event_lock);
+
list_add_tail(&dev->node, &input_dev_list);
list_for_each_entry(handler, &input_handler_list, node)
next prev parent reply other threads:[~2026-10-10 22:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 22:58 [PATCH v3 0/2] Input: discard pre-registration events and test state seeding Karlos Abel
2026-10-10 22:58 ` Karlos Abel [this message]
2026-10-10 22:58 ` [PATCH v3 2/2] Input: test state seeding across device registration Karlos Abel
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=20261010225808.36404-2-kabel@voidship.net \
--to=kabel@voidship.net \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashiko-bot@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®