All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v4 1/6] HID: steam: Refactor registration
Date: Fri, 07 Aug 2026 23:36:59 +0000	[thread overview]
Message-ID: <20260807233700.D37EC1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260807232339.2799205-2-vi@endrift.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Use-After-Free of steam_device due to orphaned work items on device removal after partial registration failure.
--

--- Patch [1]: [PATCH v4 1/6] HID: steam: Refactor registration ---
commit 2f71fd5dc6effb1149cad5cc15145d4c5b501691
Author: Vicki Pfau <vi@endrift.com>

HID: steam: Refactor registration

This refactors and simplifies the registration/unregistration flow, replacing
the previous assumption that a serial number means the device is registered
with a single purpose boolean, and fixes a power_supply object leak on error
paths.

> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
> @@ -1149,66 +1147,60 @@ static int steam_register(struct steam_device *steam)

[ ... ]

>  steam_register_sensors_fail:
>  	steam_input_unregister(steam);
>  steam_register_input_fail:
> +	steam_battery_unregister(steam);
>  	return ret;
>  }
>  
>  static void steam_unregister(struct steam_device *steam)
>  {
> -	if (!steam->serial_no[0])
> +	if (!steam->registered)
>  		return;

[Severity: High]
Could this early return cause a use-after-free of the steam_device structure
if steam_register() partially fails?

If steam_register() successfully registers the input device but then fails
during steam_sensors_register(), incoming HID reports processed by
steam_raw_event() can schedule the mode_switch delayed work during that short
window.

The error path in steam_register() unregisters the input device but leaves
steam->registered as false without cancelling any scheduled work items.

When the device is later disconnected, steam_remove() calls
steam_unregister(). Because steam->registered is false, it returns
immediately and skips cancelling the work items.

After steam_remove() returns and the steam_device structure is freed by
devres, could the pending delayed work fire and dereference the freed pointer?

>  
>  	hid_info(steam->hdev, "Steam Controller '%s' disconnected",
>  			steam->serial_no);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260807232339.2799205-1-vi@endrift.com?part=1

  reply	other threads:[~2026-08-07 23:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 23:23 [PATCH v4 0/6] HID: steam: Add 2026 Steam Controller support Vicki Pfau
2026-08-07 23:23 ` [PATCH v4 1/6] HID: steam: Refactor registration Vicki Pfau
2026-08-07 23:36   ` sashiko-bot [this message]
2026-08-07 23:23 ` [PATCH v4 2/6] HID: steam: Initial 2026 Steam Controller support Vicki Pfau
2026-08-07 23:59   ` sashiko-bot
2026-08-07 23:23 ` [PATCH v4 3/6] HID: steam: Fix wording of connect/disconnect logs Vicki Pfau
2026-08-07 23:23 ` [PATCH v4 4/6] HID: steam: Don't set feature reports when disconnecting Vicki Pfau
2026-08-07 23:48   ` sashiko-bot
2026-08-07 23:23 ` [PATCH v4 5/6] HID: steam: Clean up locking Vicki Pfau
2026-08-07 23:53   ` sashiko-bot
2026-08-07 23:23 ` [PATCH v4 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=20260807233700.D37EC1F00A3D@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.