From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v3 1/6] HID: steam: Unregister battery on partial registration error
Date: Fri, 07 Aug 2026 01:53:51 +0000 [thread overview]
Message-ID: <20260807015351.75CAF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807013334.2109386-2-vi@endrift.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Tearing down the battery on the error path without clearing `steam->serial_no` prevents battery registration on subsequent retries.
Pre-existing issues:
- [High] Concurrent execution of unregistration functions allows unprotected RCU pointer modifications, causing potential double frees.
--
--- Patch [1]: [PATCH v3 1/6] HID: steam: Unregister battery on partial registration error ---
commit 024061e54a475950f36c1803b7d20aeb74ac4f96
Author: Vicki Pfau <vi@endrift.com>
HID: steam: Unregister battery on partial registration error
In a previous refactor the code for unregistering a battery if later
registration steps failed was accidentally left out. As a result, a
lingering power_supply object could get left over after the steam object
was torn down.
> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> index 6199f67f3c4cd..967f12c7a599a 100644
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
> @@ -1199,6 +1199,7 @@ static int steam_register(struct steam_device *steam)
> steam_register_sensors_fail:
> steam_input_unregister(steam);
> steam_register_input_fail:
> + steam_battery_unregister(steam);
[Severity: Medium]
Will this error path leave the device in an inconsistent state on retry?
If steam_register() fails and steam_battery_unregister() is called,
steam->serial_no[0] is not cleared.
On a subsequent retry (e.g. from steam_work_connect_cb()), steam_register()
will see the serial number populated and skip the initialization block where
steam_battery_register() is called.
This results in the input devices registering successfully, but the battery
object being permanently missing until a full device disconnect.
[Severity: High]
This is a pre-existing issue, but does calling steam_battery_unregister()
here expose a race condition?
When a user holds the HID device open, hid_hw_close(hdev) in steam_remove()
doesn't drop ll_open_count to zero, leaving the interrupt URB active.
After cancel_work_sync(&steam->work_connect), the active URB can still
receive raw events and re-queue work_connect.
This allows a worker thread to execute steam_register() or
steam_unregister() concurrently with steam_remove().
Since steam_battery_unregister() only uses rcu_read_lock() for reads, both
threads can observe a non-NULL battery pointer:
drivers/hid/hid-steam.c:steam_battery_unregister() {
rcu_read_lock();
battery = rcu_dereference(steam->battery);
rcu_read_unlock();
if (!battery)
return;
RCU_INIT_POINTER(steam->battery, NULL);
synchronize_rcu();
power_supply_unregister(battery);
devm_kfree(&steam->hdev->dev, steam->battery_desc.name);
}
Is it possible for both threads to proceed past the NULL check and
double-free the battery and its memory?
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807013334.2109386-1-vi@endrift.com?part=1
next prev parent reply other threads:[~2026-08-07 1:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 1:33 [PATCH v3 0/6] HID: steam: Add 2026 Steam Controller support Vicki Pfau
2026-08-07 1:33 ` [PATCH v3 1/6] HID: steam: Unregister battery on partial registration error Vicki Pfau
2026-08-07 1:53 ` sashiko-bot [this message]
2026-08-07 1:33 ` [PATCH v3 2/6] HID: steam: Initial 2026 Steam Controller support Vicki Pfau
2026-08-07 2:07 ` sashiko-bot
2026-08-07 1:33 ` [PATCH v3 3/6] HID: steam: Fix wording of connect/disconnect logs Vicki Pfau
2026-08-07 1:33 ` [PATCH v3 4/6] HID: steam: Don't set feature reports when disconnecting Vicki Pfau
2026-08-07 1:33 ` [PATCH v3 5/6] HID: steam: Clean up locking Vicki Pfau
2026-08-07 1:56 ` sashiko-bot
2026-08-07 1:33 ` [PATCH v3 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=20260807015351.75CAF1F000E9@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