From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A90A939A060 for ; Sat, 10 Oct 2026 22:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791673094; cv=none; b=N7/qLLkMIcGhYV244CvfVOktjgLiyl12Od0ztUEqxFHglyemsl8OG22SWK9wa1Di4zRqdLra7uqgvrvw/QcgMEOGPVsJfYYjRFQRsgejq6UAZ31dINxKluIDxSgJ8nsXLAxEEaS+pRLZ1AbBvqaMkA9lrnE0iYAaN7oAokyv4no= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791673094; c=relaxed/simple; bh=a3o4+h0aIyuPfIMWpB+WMMdkFGVQzVcX12UNoZmJDqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MkIbVFNIwQ7kjjHMLSLpP2Tr1/+/ix56/maRRKcV7i12p8muRYgtHlmrGGzPpL/4/637YLb96Fe5Khc9PpCEQ0VOYMKTosLlZHDK9PDEEPY0NC2jfUp7267rYgJZDTsI43P2seNLR5xiO8Lzgw4jXKaKmtlaLWQJFdd5qHB8sM8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=voidship.net; spf=pass smtp.mailfrom=voidship.net; dkim=pass (2048-bit key) header.d=voidship-net.20251104.gappssmtp.com header.i=@voidship-net.20251104.gappssmtp.com header.b=D3ZYqMYL; arc=none smtp.client-ip=209.85.219.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=voidship.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=voidship.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=voidship-net.20251104.gappssmtp.com header.i=@voidship-net.20251104.gappssmtp.com header.b="D3ZYqMYL" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-91b66c64a18so11531146d6.1 for ; Sat, 10 Oct 2026 15:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=voidship-net.20251104.gappssmtp.com; s=20251104; t=1791673091; x=1792277891; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Eq3BGcj94f52kevMdVzNWJuAe2KKsdp6kTmWDqj11yo=; b=D3ZYqMYLK7AoGNx8QW0Ysv1xZVKc9dGXyGlL0enbITzdl4h1Fy3rwNtp151l6ryeuF VOCCkXfnsTw20/3sUo2SoEcg5xObhoaKbLJjVhWA2cOCl1KHQalY/Cee3ISjfx2vfMB7 kdFwuhCp4dAeMiQIQETQ4yaAjmipwBfV8qW+InyWqUaqbaUWhbqlLWb4Y8c1yOTzD3FI DnCAWL5axq9k/Wi+iuxHb2Y6tcw8Gl3a7Qh/miiJJL/fpNa+0Y4BwlysRICLrUwBXoIb 6Axk7C5GH+HVQ3G6Gxy8Xctx1WCoyLDBrMcKjljFg8epY+ArDjVdgD9rB9SRCC28sq47 sLRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791673091; x=1792277891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Eq3BGcj94f52kevMdVzNWJuAe2KKsdp6kTmWDqj11yo=; b=K2N2wnqQlQ0vovRu5Lu9+qmD+EYg/l1am5o7jO822q05OjFAptjWYD4cAQtkp6I2Mj IaFTIv+cCbxuQm8co8X3P/ICEIaccMlsenNY5PNTPJzucIXqCSco5QCketxuJxuZDAKc 35qBGitKw1MSXW81bPYDbuZkK58UxdJhMvhYdgxlZbO1pCQszdPqG3a8Py97sD0n/oQe f49ZnAffdQbcv/e0bMl/Vam68GHYhUj7jhV3x9G4Jn1cBc8FNkLgWlUOUQjYCyHQNGSb siZZa/ESg6siX518iwbWXIV83go1fgQ2QYaR3EqpR7K78nKMeGF6yita9OSrH/cFqNLS GQ8A== X-Forwarded-Encrypted: i=1; AKwUvBxUYU2t4iZ/THHmgtvvRMT4Pu5LWKZjDg12ftT1tPaLKs6O+NWHjlf1QWnXFK05FO1knekKf6BSVJ5PVxw=@vger.kernel.org X-Gm-Message-State: AFq9FYKbhN6V3EWLqIkcrHbPJki2QP9+AQVdHRcAB0+1lpaCN+XC+WhD F3EpFuwLVtYixVdwhJAT0VjRHcbclWORb85IZB0OYL+RbXr8X22kgU7Ouv/TnWqGNfmWJeZTvLj dY9W+/iA= X-Gm-Gg: AYBFou3F7SI6/ZFHYebnJA/OIQeKonWo5VO04UlXX+qri95APGnFjRqkVZtZRFlsPIG 5SuMm7ddwPJe/qMDSGg2mjXG9AM053r4cTmtoCaPPmZcacC9q9+uNYskKZDG7dS1Dyh2z8rQsHo F1Gy6noirPOCMYtxNAE8ZqpzwpDCgeBRBj642KoSmPoA/OB1zA+NqRMcZTdjNazT0bZSUfE5Ozv 8QXXtTqgTuX+JT64b4El3BtDX+/tEeCVLeZW6IQkAb9pIiagl08o1TOSezqLmaTBKd3mY5LputU UH8fQoYn327EzHHLjsUOXM79R7p3sxQKnhP90g9XkkxJrH9YXUuWrY4hbMzB80oYmOOTdcFwqad /LKnCgOoKlOGDQ/SshAkJYteidWijpI4L7maQvcgga4iKWvKPoNKjZ02KXNUpnO4Z3jLBJoy8P5 eX513mmBLOZIo3FS1TXU9SUgHuLmzzfuoQIX3ZNv1pPiNLrI3qeHynNYrHHD9cSNIIPnLehF4sA EAWcJEVvICAZeF7Yqh0HzkXsZIcwzrusYaWfjKJqA== X-Received: by 2002:ad4:5def:0:b0:910:5bb4:8407 with SMTP id 6a1803df08f44-91b53592b3amr106822606d6.0.1791673091356; Sat, 10 Oct 2026 15:58:11 -0700 (PDT) Received: from boomzilla (dynamic-acs-24-101-237-49.zoominternet.net. [24.101.237.49]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91b55092ca8sm55498256d6.37.2026.10.10.15.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2026 15:58:10 -0700 (PDT) From: Karlos Abel To: Dmitry Torokhov 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 Message-ID: <20261010225808.36404-2-kabel@voidship.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261010225808.36404-1-kabel@voidship.net> References: <20261010225808.36404-1-kabel@voidship.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 #include #include +#include #include #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)