hdaps_invert_store() sets hdaps_invert and calls hdaps_calibrate() without hdaps_mtx. The comment above hdaps_calibrate() says that callers must hold the mutex, and hdaps_calibrate_store() and hdaps_mousedev_poll() do. hdaps_calibrate() reads the axes with __hdaps_read_pair(), which runs a refresh/read/complete sequence on the embedded controller's I/O ports and then applies hdaps_invert. A write to the invert attribute can therefore interleave its port accesses with those of the input poller. The poller can also use rest_x/rest_y while they are being recalibrated, or together with an hdaps_invert value they were not measured with. Both lead to wrong position reports. Take hdaps_mtx around the update, as hdaps_calibrate_store() does. The missing lock was found by a static check that turns the locking rule in a function's comment into a Clang context-analysis requirement on its callers. Fixes: 860e1d6b46bd ("[PATCH] updated hdaps driver.") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by a compiler-based check, part of research at UCSB SecLab. The locking rule stated in the kernel-doc comment of the called function was turned into a Clang context-analysis requirement (__must_hold) on that function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every caller. An LLM was used only to turn the comment into a machine-readable rule; the report itself comes from the compiler. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64, clang 23, allmodconfig). Not runtime-tested; I do not have this hardware, and I have not observed the race myself. drivers/platform/x86/hdaps.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/hdaps.c b/drivers/platform/x86/hdaps.c index f11f726d2062..993d9889fbf9 100644 --- a/drivers/platform/x86/hdaps.c +++ b/drivers/platform/x86/hdaps.c @@ -435,8 +435,10 @@ static ssize_t hdaps_invert_store(struct device *dev, invert < 0 || invert > HDAPS_BOTH_AXES) return -EINVAL; + mutex_lock(&hdaps_mtx); hdaps_invert = invert; hdaps_calibrate(); + mutex_unlock(&hdaps_mtx); return count; } -- 2.25.1