Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sriman Achanta" <srimanachanta@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v7 3/8] HID: steelseries: Refactor Arctis driver to use device_info framework
Date: Mon, 03 Aug 2026 19:25:56 +0000	[thread overview]
Message-ID: <20260803192557.9E9F11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260803191553.66368-4-srimanachanta@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Race condition exposing ERR_PTR leading to kernel panic in raw_event.
--

--- Patch [3]: [PATCH v7 3/8] HID: steelseries: Refactor Arctis driver to use device_info framework ---
commit e1b5fdcaec23ba5cc7a2a2139ba1c9fa983d7894
Author: Sriman Achanta <srimanachanta@gmail.com>

HID: steelseries: Refactor Arctis driver to use device_info framework

This commit refactors the Arctis driver to use a device_info struct
instead of a quirk bitmap for device capabilities. It also changes
battery polling to use a periodic delayed work instead of being
requested from raw_event.

> diff --git a/drivers/hid/hid-steelseries-arctis.c b/drivers/hid/hid-steelseries-arctis.c
> index 6cae2e00bd8ba..c54c56db9ddd7 100644
> --- a/drivers/hid/hid-steelseries-arctis.c
> +++ b/drivers/hid/hid-steelseries-arctis.c
[ ... ]
> @@ -177,25 +271,27 @@ static int steelseries_headset_battery_register(struct steelseries_device *sd)
[ ... ]
>  	sd->battery = devm_power_supply_register(&sd->hdev->dev,
>  			&sd->battery_desc, &battery_cfg);
>  	if (IS_ERR(sd->battery)) {
>  		ret = PTR_ERR(sd->battery);
> +		sd->battery = NULL;
>  		hid_err(sd->hdev,
>  				"%s:power_supply_register failed with error %d\n",
>  				__func__, ret);

[Severity: High]
Could this assignment expose an ERR_PTR to a concurrent event handler?

Because hid_hw_start() and hid_hw_open() are called before 
steelseries_battery_register() in steelseries_arctis_probe(), USB interrupts 
can trigger steelseries_arctis_raw_event() concurrently.

If devm_power_supply_register() fails due to memory pressure or other errors, 
sd->battery will briefly hold an ERR_PTR before it is set to NULL. A 
concurrent execution of raw_event() evaluates if (sd->battery). Since an 
ERR_PTR is not NULL, the check passes, and power_supply_changed(sd->battery) 
will dereference the invalid pointer, causing a kernel panic.

Would it be safer to assign the return value to a local variable first, and 
only assign it to sd->battery upon success?

Additionally, does the unconditional assignment of sd->battery_capacity = 100 
just before registration risk silently overwriting a real status update 
received by raw_event() during this window?

[ ... ]
> @@ -272,142 +365,92 @@ static void steelseries_arctis_remove(struct hid_device *hdev)
[ ... ]
> -	if (connected != sd->headset_connected) {
> -		hid_dbg(sd->hdev,
> +	if (sd->headset_connected != old_connected) {
> +		hid_dbg(hdev,
>  			"Connected status changed from %sconnected to %sconnected\n",
> -			sd->headset_connected ? "" : "not ",
> -			connected ? "" : "not ");
> -		sd->headset_connected = connected;
> -		steelseries_headset_set_wireless_status(hdev, connected);
> +			old_connected ? "" : "not ",
> +			sd->headset_connected ? "" : "not ");
> +
> +		if (sd->battery) {
> +			steelseries_headset_set_wireless_status(sd->hdev,
> +							       sd->headset_connected);
> +			power_supply_changed(sd->battery);
> +		}
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260803191553.66368-1-srimanachanta@gmail.com?part=3

  reply	other threads:[~2026-08-03 19:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 19:15 [PATCH v7 0/8] HID: steelseries: split out Arctis driver and add Nova 5X/Nova 7 support Sriman Achanta
2026-08-03 19:15 ` [PATCH v7 1/8] HID: steelseries: Fix ARCTIS_1_X device mislabeling Sriman Achanta
2026-08-03 19:15 ` [PATCH v7 2/8] HID: steelseries: Split Arctis headset driver into separate module Sriman Achanta
2026-08-03 19:15 ` [PATCH v7 3/8] HID: steelseries: Refactor Arctis driver to use device_info framework Sriman Achanta
2026-08-03 19:25   ` sashiko-bot [this message]
2026-08-03 19:15 ` [PATCH v7 4/8] HID: steelseries: Report POWER_SUPPLY_STATUS_FULL when full Sriman Achanta
2026-08-03 19:15 ` [PATCH v7 5/8] HID: steelseries: Correct Arctis 9 battery calibration range Sriman Achanta
2026-08-03 19:15 ` [PATCH v7 6/8] HID: steelseries: Manage battery lifetime with refcounting Sriman Achanta
2026-08-03 19:29   ` sashiko-bot
2026-08-03 19:15 ` [PATCH v7 7/8] HID: steelseries: Add async status interface support Sriman Achanta
2026-08-03 19:29   ` sashiko-bot
2026-08-03 19:15 ` [PATCH v7 8/8] HID: steelseries: Add support for Arctis Nova 5X and Nova 7 families Sriman Achanta
2026-08-03 19:32 ` [PATCH v7 0/8] HID: steelseries: split out Arctis driver and add Nova 5X/Nova 7 support Jiri Kosina
2026-08-05  0:26   ` Benjamin Wheeler

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=20260803192557.9E9F11F00A3A@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=srimanachanta@gmail.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