From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v5 4/6] HID: steam: Don't set feature reports when disconnecting
Date: Wed, 12 Aug 2026 01:35:04 +0000 [thread overview]
Message-ID: <20260812013504.8936C1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260812011401.3250968-5-vi@endrift.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-after-free in steam_remove() due to incorrect cancellation order of deferred work.
--
--- Patch [4]: [PATCH v5 4/6] HID: steam: Don't set feature reports when disconnecting ---
commit 460f363e27307cbdb952f6004dd3826de0898a07
Author: Vicki Pfau <vi@endrift.com>
HID: steam: Don't set feature reports when disconnecting
When an input device is closed, we set a feature report to reset lizard
mode and IMU mode. However, if the input device is closed because it was
removed, then we will necessarily error out when sending this, resulting in
logged errors. Since an error here is expected, we should just fail
silently.
> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> index 461ebf37171b7..7226c0681ed18 100644
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
> @@ -490,9 +490,13 @@ static int steam_recv_report_id(struct steam_device *steam,
> }
>
> kfree(buf);
> - if (ret < 0)
> + /*
> + * Don't log if the failure is -ENODEV, as this
> + * can happen normally on disconnect.
> + */
> + if (ret < 0 && ret != -ENODEV)
> hid_err(steam->hdev, "%s: error %d\n", __func__, ret);
[Severity: High]
This is a pre-existing issue, but while reviewing device disconnects, I
noticed a potential use-after-free during device removal in steam_remove().
Looking at steam_remove(), cancel_work_sync(&steam->work_connect) is called
before hid_hw_stop(hdev):
drivers/hid/hid-steam.c:steam_remove() {
...
cancel_work_sync(&steam->work_connect);
if (steam->quirks & STEAM_QUIRK_WIRELESS) {
hid_info(hdev, "Steam wireless receiver disconnected");
}
steam_unregister(steam);
hid_hw_stop(hdev);
}
Because hid_hw_stop() is called last, hardware interrupts can still trigger
steam_raw_event() after the work item is cancelled. If a wireless connection
event (ID_CONTROLLER_WIRELESS) or an unexpected input report arrives during
this window, steam_raw_event() will invoke steam_do_connect_event(), which
re-schedules steam->work_connect:
drivers/hid/hid-steam.c:steam_raw_event() {
...
case ID_CONTROLLER_WIRELESS:
...
switch (data[4]) {
...
case 0x02:
steam_do_connect_event(steam, true);
break;
...
}
After steam_remove() returns and the device memory is freed by devres, the
workqueue retains the pending work, which could access the freed memory when
it runs.
Should hid_hw_stop(hdev) be called before cancel_work_sync() to ensure no new
events can queue the work?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812011401.3250968-1-vi@endrift.com?part=4
next prev parent reply other threads:[~2026-08-12 1:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 1:13 [PATCH v5 0/6] HID: steam: Add 2026 Steam Controller support Vicki Pfau
2026-08-12 1:13 ` [PATCH v5 1/6] HID: steam: Refactor registration Vicki Pfau
2026-08-12 1:13 ` [PATCH v5 2/6] HID: steam: Initial 2026 Steam Controller support Vicki Pfau
2026-08-12 1:13 ` [PATCH v5 3/6] HID: steam: Fix wording of connect/disconnect logs Vicki Pfau
2026-08-12 1:13 ` [PATCH v5 4/6] HID: steam: Don't set feature reports when disconnecting Vicki Pfau
2026-08-12 1:35 ` sashiko-bot [this message]
2026-08-12 1:13 ` [PATCH v5 5/6] HID: steam: Clean up locking Vicki Pfau
2026-08-12 1:38 ` sashiko-bot
2026-08-12 1:13 ` [PATCH v5 6/6] HID: steam: Zero out inputs when disabling gamepad mode Vicki Pfau
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=20260812013504.8936C1F00A3A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox