]> git.hungrycats.org Git - linux/commit
HID: hid-lenovo-go-s: Bound stale reply window before reusing send_cmd_complete
authorDerek J. Clark <derekjohn.clark@gmail.com>
Mon, 14 Sep 2026 22:52:55 +0000 (15:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:51 +0000 (12:10 -0500)
commit542a74e19639ac0e35979189bf7ec0ed022f8644
treed28b9345e1946394c3513ba0f56cb7e4319d5300
parentcd4a95557f3c156bf06bb2e2b5667d59343ebdb2
HID: hid-lenovo-go-s: Bound stale reply window before reusing send_cmd_complete

commit 6224755416e627badf69b330afec9ac6b85e5098 upstream.

mcu_property_out() reinits send_cmd_complete immediately after a
timeout is detected, before the next command that reuses it is sent.
If the MCU's reply to the timed-out command arrives after this reinit
but before the next command's wait begins, it silently satisfies the
next, unrelated command's wait instead of the one it actually answers,
handing that caller stale data with no way to detect the mismatch.

Track when a command has timed out via cmd_orphaned. Before the next
command reuses the completion, wait a bounded 25ms for a stale reply
to arrive and be consumed, then unconditionally clear the flag and
reinit the completion. This does not fully eliminate the window in
which an unrelated reply could still be received, but bounds it to
a short interval right before a new command is sent. Behavior matches
the solution to the same problem in hid-msi.

Fixes: a23f3497bf208c59ad ("HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/hid-lenovo-go-s.c