From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 5/5] HID: steam: Zero out inputs when disabling gamepad mode
Date: Wed, 05 Aug 2026 02:09:01 +0000 [thread overview]
Message-ID: <20260805020901.721DE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805015116.3884465-6-vi@endrift.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] AB-BA deadlock between `report_mutex` and workqueues during device unregistration.
Pre-existing issues:
- [High] Concurrent unregistration in `steam_probe` error path leads to a double free of input devices.
--
--- Patch [5]: [PATCH 5/5] HID: steam: Zero out inputs when disabling gamepad mode ---
commit 7a64f604e0a34949b1434a03544f0ca71ef9305f
Author: Vicki Pfau <vi@endrift.com>
HID: steam: Zero out inputs when disabling gamepad mode
When gamepad mode is disabled the gamepad input devices will stop receiving
updates. However, in the case where there are buttons still pressed this
will appear as an indefinitely-held button. Instead we should zero out the
inputs to make it look like things are all released.
> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> index 87af4bee9f5ff..93a6f4e17fb75 100644
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
> @@ -1490,11 +1490,76 @@ static void steam_mode_switch_cb(struct work_struct *work)
>
> guard(mutex)(&steam->report_mutex);
[Severity: High]
Is there a risk of an AB-BA deadlock here during device unregistration?
If steam_remove() is called and acquires steam->report_mutex, it then calls
steam_unregister(). If steam_unregister() then calls
cancel_delayed_work_sync(&steam->mode_switch) while the mutex is held:
steam_remove()
guard(mutex)(&steam->report_mutex);
steam_unregister(steam);
cancel_delayed_work_sync(&steam->mode_switch);
This workqueue callback would block here attempting to acquire the same
steam->report_mutex, while steam_remove() blocks waiting for this work
to finish. Since the wait condition is permanent, this could hang the USB/HID
hotplug subsystem.
[ ... ]
[Severity: High]
This is a pre-existing issue, but could the error path in steam_probe() race
with disconnect events and cause a double-free of the input devices?
If steam_probe() fails in hid_add_device(), it jumps to err_steam_unregister
and calls steam_unregister() if steam->connected is true (checked locklessly):
steam_probe():
err_steam_unregister:
if (steam->connected)
steam_unregister(steam);
Because hid_device_io_start() was already called, a concurrent disconnect
event can queue steam_work_connect_cb(). If that worker runs, sees
connected == false, and also calls steam_unregister(steam), both threads can
concurrently enter steam_input_unregister() since the error path does not
hold report_mutex.
Both threads would then read steam->input, find it valid, set it to NULL
locklessly, and call input_unregister_device() on the same pointer:
steam_input_unregister():
input = rcu_dereference(steam->input);
...
RCU_INIT_POINTER(steam->input, NULL);
...
input_unregister_device(input);
Can this lead to a double-free of the input_dev structure?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805015116.3884465-1-vi@endrift.com?part=5
prev parent reply other threads:[~2026-08-05 2:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 1:51 [PATCH 0/5] HID: steam: Add 2026 Steam Controller support Vicki Pfau
2026-08-05 1:51 ` [PATCH 1/5] HID: steam: Initial " Vicki Pfau
2026-08-05 2:13 ` sashiko-bot
2026-08-05 1:51 ` [PATCH 2/5] HID: steam: Fix wording of connect/disconnect logs Vicki Pfau
2026-08-05 2:02 ` sashiko-bot
2026-08-05 1:51 ` [PATCH 3/5] HID: steam: Don't set feature reports when disconnecting Vicki Pfau
2026-08-05 1:51 ` [PATCH 4/5] HID: steam: Clean up locking Vicki Pfau
2026-08-05 2:16 ` sashiko-bot
2026-08-05 1:51 ` [PATCH 5/5] HID: steam: Zero out inputs when disabling gamepad mode Vicki Pfau
2026-08-05 2:09 ` sashiko-bot [this message]
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=20260805020901.721DE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vi@endrift.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.