From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Pawel Zalewski" <pzalewski@thegoodpenguin.co.uk>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Ronald Tschalär" <ronald@innovation.ch>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH v2 2/3] Input: applespi - disable touchpad registration work on removal
Date: Fri, 27 Nov 2026 14:51:55 +0000 [thread overview]
Message-ID: <20261127145209.2884170-3-lee@kernel.org> (raw)
In-Reply-To: <20261127145209.2884170-1-lee@kernel.org>
applespi_probe() allocates its driver state with devm_kzalloc_obj() and
initiates an asynchronous touchpad information query whose completion
schedules applespi->work to allocate and register the managed touchpad
input device in applespi_worker().
applespi_remove() disables the ACPI GPE and drains in-flight SPI writes
and reads, but never disables applespi->work. If a touchpad info
response scheduled applespi->work just before applespi_drain_reads()
completed, applespi_worker() can run during or after devres teardown,
corrupting the device resource list via devm_input_allocate_device() and
dereferencing freed driver data.
Disable applespi->work synchronously after applespi_drain_reads(), once
no further SPI responses can schedule it.
Fixes: 038b1a05eae6 ("Input: add Apple SPI keyboard and trackpad driver")
Closes: https://sashiko.dev/#/bug/linux-bb2fd773-6c20-468c-a092-6814f008077f
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
v1 => v2:
- Use disable_work_sync() instead of cancel_work_sync() in applespi_remove(), per Dmitry Torokhov's review.
drivers/input/keyboard/applespi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c
index 1d059aff1f1b..1e63719dec4b 100644
--- a/drivers/input/keyboard/applespi.c
+++ b/drivers/input/keyboard/applespi.c
@@ -1822,6 +1822,7 @@ static void applespi_remove(struct spi_device *spi)
device_wakeup_disable(&spi->dev);
applespi_drain_reads(applespi);
+ disable_work_sync(&applespi->work);
debugfs_remove_recursive(applespi->debugfs_root);
}
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-27 14:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 14:51 [PATCH v2 0/3] Input: Fix GPIO bounds, work teardown, and suspend bugs Lee Jones
2026-11-27 14:51 ` [PATCH v2 1/3] Input: matrix_keypad - validate GPIO counts against matrix limits Lee Jones
2026-11-27 14:51 ` Lee Jones [this message]
2026-11-27 14:51 ` [PATCH v2 3/3] Input: matrix_keypad - only stop and start active device across sleep Lee Jones
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=20261127145209.2884170-3-lee@kernel.org \
--to=lee@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pzalewski@thegoodpenguin.co.uk \
--cc=ronald@innovation.ch \
--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®