HID: steam: Add 2026 Steam Controller support
Subsystems (2)
Vicki Pfau
maintainerv2 cover HID: steam: Add 2026 Steam Controller support
This is the second half of a series that modernizes the hid-steam controller. It adds support for the new 2026 Steam Controller, with feature parity compared to the 2015 model and the Steam Deck drivers, as well as some smaller cleanup. The biggest cleanup is cleaning up the somewhat lax locking practices, but a few more minor things exposed to userspace include logging improvements and zeroing inputs when switching from gamepad mode to lizard mode.
This fixes up a few things from the last version, including some potential deadlocks and adding a missing battery unregistration that made it through the last series.
Vicki Pfau (6):
HID: steam: Unregister battery on partial registration error
HID: steam: Initial 2026 Steam Controller support
HID: steam: Fix wording of connect/disconnect logs
HID: steam: Don't set feature reports when disconnecting
HID: steam: Clean up locking
HID: steam: Zero out inputs when disabling gamepad mode
drivers/hid/hid-ids.h | 4 + drivers/hid/hid-steam.c | 1008 ++++++++++++++++++++++++++++++++------- 2 files changed, 831 insertions(+), 181 deletions(-)
Signature · 1 line
2.54.0
Vicki Pfau
maintainerPATCH v2 1/6 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.
--- drivers/hid/hid-steam.c | 1 + 1 file changed, 1 insertion(+)
drivers/hid/hid-steam.c +1 -0
@@ -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);return ret; }
Signature · 1 line
2.54.0
Vicki Pfau
maintainerPATCH v2 2/6 HID: steam: Initial 2026 Steam Controller support
In reply to Vicki PfauThis brings support for the 2026 Steam Controller, comparably featureful to the existing support for the Steam Deck.
--- drivers/hid/hid-ids.h | 4 + drivers/hid/hid-steam.c | 846 +++++++++++++++++++++++++++++++++------- 2 files changed, 710 insertions(+), 140 deletions(-)
drivers/hid/hid-ids.h +4 -0
@@ -1374,6 +1374,10 @@#define USB_DEVICE_ID_STEAM_CONTROLLER 0x1102#define USB_DEVICE_ID_STEAM_CONTROLLER_WIRELESS 0x1142#define USB_DEVICE_ID_STEAM_DECK 0x1205 +#define USB_DEVICE_ID_STEAM_CONTROLLER_IBEX 0x1302 +#define USB_DEVICE_ID_STEAM_CONTROLLER_IBEX_BLE 0x1303 +#define USB_DEVICE_ID_STEAM_CONTROLLER_PROTEUS 0x1304 +#define USB_DEVICE_ID_STEAM_CONTROLLER_NEREID 0x1305#define USB_VENDOR_ID_STEELSERIES 0x1038#define USB_DEVICE_ID_STEELSERIES_SRWS1 0x1410
drivers/hid/hid-steam.c +706 -140
1,171 lines not on this page · raw message
Signature · 1 line
2.54.0
Vicki Pfau
maintainerPATCH v2 3/6 HID: steam: Fix wording of connect/disconnect logs
In reply to Vicki PfauIt always said Controller, even on Deck. Since we special-case other instances of Controller vs. Deck in strings, let's be consistent here too.
--- drivers/hid/hid-steam.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/hid/hid-steam.c +4 -2
@@ -1394,7 +1394,8 @@ static int steam_register(struct steam_device *steam)"%s:steam_get_attributes failed with error %d\n" , __func__, ret); -hid_info (steam->hdev,"Steam Controller '%s' connected" , +hid_info (steam->hdev,"Steam %s '%s' connected" , + steam->quirks &STEAM_QUIRK_DECK ?"Deck" :"Controller" , steam->serial_no);/* ignore battery errors, we can live without it */
@@ -1427,7 +1428,8 @@ static void steam_unregister(struct steam_device *steam)if (!steam->serial_no[0 ])return ; -hid_info (steam->hdev,"Steam Controller '%s' disconnected" , +hid_info (steam->hdev,"Steam %s '%s' disconnected" , + steam->quirks &STEAM_QUIRK_DECK ?"Deck" :"Controller" , steam->serial_no);steam_battery_unregister (steam);steam_sensors_unregister (steam);
Signature · 1 line
2.54.0
Vicki Pfau
maintainerPATCH v2 4/6 HID: steam: Don't set feature reports when disconnecting
In reply to Vicki PfauWhen 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.
--- drivers/hid/hid-steam.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/hid/hid-steam.c +11 -3
@@ -489,9 +489,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); -else +else if (ret >0 )hid_dbg (steam->hdev,"Received report %*ph\n" , size, data);if (ret <0 )return ret;
@@ -569,7 +573,11 @@ static int steam_send_report_id(struct steam_device *steam, }while (--retries);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 (%*ph)\n" , __func__, ret, size, cmd);return ret;
Signature · 1 line
2.54.0
Vicki Pfau
maintainerPATCH v2 5/6 HID: steam: Clean up locking
In reply to Vicki PfauThis cleans up several issues with locking behavior, including RCU accesses not being guarded behind a lock.
--- drivers/hid/hid-steam.c | 90 +++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 43 deletions(-)
drivers/hid/hid-steam.c +47 -43
@@ -632,7 +632,6 @@ static int steam_exchange_report(struct steam_device *steam, u8 *cmd, int csize,unsigned int retries =5 ;int ret; -guard (mutex)(&steam->report_mutex); do { ret = steam_send_report(steam, cmd, csize); if (ret < 0)
@@ -786,7 +785,6 @@ static inline int steam_haptic_pulse(struct steam_device *steam, u8 pad, report[8 ] = count >>8 ; report[9 ] = gain; -guard (mutex)(&steam->report_mutex); ret =steam_send_report (steam, report,10 ); }
@@ -828,7 +826,6 @@ static inline int steam_haptic_rumble(struct steam_device *steam, report[9 ] = left_gain; report[10 ] = right_gain; -guard (mutex)(&steam->report_mutex); ret =steam_send_report (steam, report,sizeof (report)); }return ret;
@@ -839,8 +836,10 @@ static void steam_haptic_rumble_cb(struct work_struct *work) struct steam_device *steam = container_of(work, struct steam_device, rumble_work); +mutex_lock (&steam->report_mutex);steam_haptic_rumble (steam,0 , steam->rumble_left, steam->rumble_right,2 ,0 ); +mutex_unlock (&steam->report_mutex); }static void steam_coalesce_rumble_cb (struct work_struct *work)
@@ -849,8 +848,10 @@ static void steam_coalesce_rumble_cb(struct work_struct *work) struct steam_device, coalesce_rumble_work); +mutex_lock (&steam->report_mutex);steam_haptic_rumble (steam,0 , steam->rumble_left, steam->rumble_right,2 ,0 ); +mutex_unlock (&steam->report_mutex);if (steam->rumble_left || steam->rumble_right)schedule_delayed_work (&steam->coalesce_rumble_work,HZ /20 );
@@ -882,7 +883,6 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)if (steam->gamepad_mode) enable = false; -mutex_lock (&steam->report_mutex);if (enable) {/* enable esc, enter, cursors */ steam_send_report_byte (steam,ID_SET_DEFAULT_DIGITAL_MAPPINGS );
@@ -905,14 +905,13 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)SETTING_RIGHT_TRACKPAD_MODE ,TRACKPAD_NONE ,/* disable mouse */ 0); } -mutex_unlock (&steam->report_mutex); }static int steam_input_open (struct input_dev *dev) {struct steam_device *steam =input_get_drvdata (dev);unsigned long flags; -bool set_lizard_mode; +bool client_opened;/* * Disabling lizard mode automatically is only done on the Steam
@@ -921,9 +920,10 @@ static int steam_input_open(struct input_dev *dev)*/ if (!(steam->quirks & (STEAM_QUIRK_DECK |STEAM_QUIRK_IBEX ))) {spin_lock_irqsave (&steam->lock, flags); - set_lizard_mode = !steam->client_opened && lizard_mode; + client_opened = steam->client_opened;spin_unlock_irqrestore (&steam->lock, flags); -if (set_lizard_mode) +guard (mutex)(&steam->report_mutex); +if (!client_opened && lizard_mode)steam_set_lizard_mode (steam, false); }
@@ -934,13 +934,14 @@ static void steam_input_close(struct input_dev *dev) {struct steam_device *steam =input_get_drvdata (dev);unsigned long flags; -bool set_lizard_mode; +bool client_opened;if (!(steam->quirks & (STEAM_QUIRK_DECK |STEAM_QUIRK_IBEX ))) {spin_lock_irqsave (&steam->lock, flags); - set_lizard_mode = !steam->client_opened && lizard_mode; + client_opened = steam->client_opened;spin_unlock_irqrestore (&steam->lock, flags); -if (set_lizard_mode) +guard (mutex)(&steam->report_mutex); +if (!client_opened && lizard_mode)steam_set_lizard_mode (steam, true); } }
@@ -948,14 +949,11 @@ static void steam_input_close(struct input_dev *dev)static int steam_sensor_open (struct input_dev *dev) {struct steam_device *steam =input_get_drvdata (dev); -unsigned long flags; -bool client_opened; -spin_lock_irqsave (&steam->lock, flags); - client_opened = steam->client_opened; -spin_unlock_irqrestore (&steam->lock, flags); -if (client_opened) -return 0 ; + scoped_guard(spinlock_irqsave, &steam->lock) { +if (steam->client_opened) +return 0 ; + }guard (mutex)(&steam->report_mutex); steam_write_settings(steam, SETTING_IMU_MODE,
@@ -968,14 +966,11 @@ static int steam_sensor_open(struct input_dev *dev)static void steam_sensor_close (struct input_dev *dev) {struct steam_device *steam =input_get_drvdata (dev); -unsigned long flags; -bool client_opened; -spin_lock_irqsave (&steam->lock, flags); - client_opened = steam->client_opened; -spin_unlock_irqrestore (&steam->lock, flags); -if (client_opened) -return ; + scoped_guard(spinlock_irqsave, &steam->lock) { +if (steam->client_opened) +return ; + }guard (mutex)(&steam->report_mutex);steam_write_settings (steam,SETTING_IMU_MODE ,0 ,0 );
@@ -1379,14 +1374,17 @@ static int steam_register(struct steam_device *steam) {int ret; +mutex_lock (&steam->report_mutex);/* * This function can be called several times in a row with the * wireless adaptor, without steam_unregister() between them, because * another client send a get_connection_status command, for example. * The battery and serial number are set just once per device. */ -if (steam->serial_no[0 ]) +if (steam->serial_no[0 ]) { +mutex_unlock (&steam->report_mutex);return 0 ; + }/* * Unlikely, but getting the serial could fail, and it is not so
@@ -1418,6 +1416,7 @@ static int steam_register(struct steam_device *steam)if (ret !=0 ) goto steam_register_sensors_fail; +mutex_unlock (&steam->report_mutex);mutex_lock (&steam_devices_lock);if (list_empty (&steam->list))list_add (&steam->list, &steam_devices);
@@ -1428,6 +1427,7 @@ static int steam_register(struct steam_device *steam)steam_input_unregister (steam); steam_register_input_fail:steam_battery_unregister (steam); +mutex_unlock (&steam->report_mutex);return ret; }
@@ -1439,9 +1439,11 @@ static void steam_unregister(struct steam_device *steam)hid_info (steam->hdev,"Steam %s '%s' disconnected" , steam->quirks &STEAM_QUIRK_DECK ?"Deck" :"Controller" , steam->serial_no); +mutex_lock (&steam->report_mutex);steam_battery_unregister (steam);steam_sensors_unregister (steam);steam_input_unregister (steam); +mutex_unlock (&steam->report_mutex);cancel_work_sync (&steam->rumble_work);cancel_delayed_work_sync (&steam->mode_switch);cancel_delayed_work_sync (&steam->coalesce_rumble_work);
@@ -1483,23 +1485,28 @@ static void steam_mode_switch_cb(struct work_struct *work) struct steam_device, mode_switch);unsigned long flags;bool client_opened; +bool gamepad_mode; +if (!lizard_mode)return ; +spin_lock_irqsave (&steam->lock, flags); steam->gamepad_mode = !steam->gamepad_mode; + gamepad_mode = steam->gamepad_mode; + client_opened = steam->client_opened; +spin_unlock_irqrestore (&steam->lock, flags); + +guard (mutex)(&steam->report_mutex);hid_dbg (steam->hdev,"%s: switching gamepad mode to %i\n" , __func__, steam->gamepad_mode); -if (steam->gamepad_mode) +if (gamepad_mode)steam_set_lizard_mode (steam, false);else { -spin_lock_irqsave (&steam->lock, flags); - client_opened = steam->client_opened; -spin_unlock_irqrestore (&steam->lock, flags);if (!client_opened)steam_set_lizard_mode (steam, lizard_mode); }steam_haptic_pulse (steam,STEAM_PAD_RIGHT ,0x190 ,0 ,1 ,0 ); -if (steam->gamepad_mode) { +if (gamepad_mode) {steam_haptic_pulse (steam,STEAM_PAD_LEFT ,0x14D ,0x14D ,0x2D ,0 ); }else {steam_haptic_pulse (steam,STEAM_PAD_LEFT ,0x1F4 ,0x1F4 ,0x1E ,0 );
@@ -1794,13 +1801,10 @@ static void steam_remove(struct hid_device *hdev)static void steam_do_connect_event (struct steam_device *steam,bool connected) { -unsigned long flags;bool changed; -spin_lock_irqsave (&steam->lock, flags); changed = steam->connected != connected; steam->connected = connected; -spin_unlock_irqrestore (&steam->lock, flags);if (changed &&schedule_work (&steam->work_connect) ==0 ) dbg_hid("%s: connected=%d event already queued\n",
@@ -2229,8 +2233,6 @@ static void steam_do_deck_sensors_event(struct steam_device *steam,static void steam_do_battery_event (struct steam_device *steam,struct power_supply *battery,u8 *data) { -unsigned long flags; -s16 volts =steam_le16 (data +12 );u8 batt = data[14 ];
@@ -2238,10 +2240,8 @@ static void steam_do_battery_event(struct steam_device *steam,rcu_read_lock (); battery =rcu_dereference (steam->battery);if (likely (battery)) { -spin_lock_irqsave (&steam->lock, flags); steam->battery_voltage = volts; steam->battery_charge = batt; -spin_unlock_irqrestore (&steam->lock, flags);power_supply_changed (battery); }rcu_read_unlock ();
@@ -2426,15 +2426,12 @@ static void steam_do_ibex_battery_event(struct steam_device *steam,struct power_supply *battery, const struct steam_ibex_battery_status *data) { - unsigned long flags; -/* Creating the battery may have failed */ guard (rcu )(); battery =rcu_dereference (steam->battery);if (!likely (battery))return ; -spin_lock_irqsave (&steam->lock, flags); steam->battery_voltage =get_unaligned_le16 (&data->battery_voltage); steam->battery_current =get_unaligned_le16 (&data->battery_current); steam->battery_temp =get_unaligned_le16 (&data->temperature);
@@ -2453,7 +2450,6 @@ static void steam_do_ibex_battery_event(struct steam_device *steam, steam->battery_status =POWER_SUPPLY_STATUS_UNKNOWN ;break ; } -spin_unlock_irqrestore (&steam->lock, flags);power_supply_changed (battery); }
@@ -2469,6 +2465,7 @@ static int steam_raw_event(struct hid_device *hdev,if (!steam)return 0 ; +guard (spinlock_irqsave)(&steam->lock);if (steam->client_opened)hid_input_report (steam->client_hdev, report->type, data, size,0 );
@@ -2632,6 +2629,8 @@ static int steam_param_set_lizard_mode(const char *val, {struct steam_device *steam;int ret; +bool client_opened; +unsigned long flags; ret =param_set_bool (val, kp);if (ret)
@@ -2639,8 +2638,13 @@ static int steam_param_set_lizard_mode(const char *val,mutex_lock (&steam_devices_lock);list_for_each_entry (steam, &steam_devices, list) { -if (!steam->client_opened) +spin_lock_irqsave (&steam->lock, flags); + client_opened = steam->client_opened; +spin_unlock_irqrestore (&steam->lock, flags); +if (!client_opened) { +guard (mutex)(&steam->report_mutex);steam_set_lizard_mode (steam, lizard_mode); + } }mutex_unlock (&steam_devices_lock);return 0 ;
Signature · 1 line
2.54.0
Vicki Pfau
maintainerPATCH v2 6/6 HID: steam: Zero out inputs when disabling gamepad mode
In reply to Vicki PfauWhen 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. We do the same thing for gyroscope inputs to make sure it doesn't look like it's endlessly rotating, but we freeze the accelerometer input since zero isn't a neutral input on the surface of the Earth.
--- drivers/hid/hid-steam.c | 69 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-)
drivers/hid/hid-steam.c +67 -2
@@ -1498,11 +1498,76 @@ static void steam_mode_switch_cb(struct work_struct *work)guard (mutex)(&steam->report_mutex);hid_dbg (steam->hdev,"%s: switching gamepad mode to %i\n" , __func__, steam->gamepad_mode); -if (gamepad_mode) +if (gamepad_mode) {steam_set_lizard_mode (steam, false); -else { + }else { +struct input_dev *input; +struct input_dev *sensors; +if (!client_opened)steam_set_lizard_mode (steam, lizard_mode); + +/* +* Zero out inputs so it doesn't look like we're holding +* anything indefinitely. +*/ +guard (spinlock_irqsave)(&steam->lock); +rcu_read_lock (); + input =rcu_dereference (steam->input); +if (likely (input)) { +input_report_key (input,BTN_TR2 ,0 ); +input_report_key (input,BTN_TL2 ,0 ); +input_report_key (input,BTN_TR ,0 ); +input_report_key (input,BTN_TL ,0 ); +input_report_key (input,BTN_Y ,0 ); +input_report_key (input,BTN_B ,0 ); +input_report_key (input,BTN_X ,0 ); +input_report_key (input,BTN_A ,0 ); +input_report_key (input,BTN_DPAD_UP ,0 ); +input_report_key (input,BTN_DPAD_RIGHT ,0 ); +input_report_key (input,BTN_DPAD_LEFT ,0 ); +input_report_key (input,BTN_DPAD_DOWN ,0 ); +input_report_key (input,BTN_SELECT ,0 ); +input_report_key (input,BTN_MODE ,0 ); +input_report_key (input,BTN_START ,0 ); +input_report_key (input,BTN_THUMBR ,0 ); +input_report_key (input,BTN_THUMBL ,0 ); +input_report_key (input,BTN_THUMB ,0 ); +input_report_key (input,BTN_THUMB2 ,0 ); +input_report_key (input,BTN_GRIPL ,0 ); +input_report_key (input,BTN_GRIPR ,0 ); + +input_report_abs (input,ABS_X ,0 ); +input_report_abs (input,ABS_Y ,0 ); +input_report_abs (input,ABS_RX ,0 ); +input_report_abs (input,ABS_RY ,0 ); +input_report_abs (input,ABS_HAT0X ,0 ); +input_report_abs (input,ABS_HAT0Y ,0 ); +input_report_abs (input,ABS_HAT2Y ,0 ); +input_report_abs (input,ABS_HAT2X ,0 ); + +if (steam->quirks & (STEAM_QUIRK_DECK |STEAM_QUIRK_IBEX )) { +input_report_key (input,BTN_BASE ,0 ); +input_report_key (input,BTN_GRIPL2 ,0 ); +input_report_key (input,BTN_GRIPR2 ,0 ); + +input_report_abs (input,ABS_HAT1X ,0 ); +input_report_abs (input,ABS_HAT1Y ,0 ); + } + +input_sync (input); + } + sensors =rcu_dereference (steam->sensors); +if (likely (sensors)) { +/* Skip accelerometers since 0 isn't a neutral input */ + +input_report_abs (sensors,ABS_RX ,0 ); +input_report_abs (sensors,ABS_RY ,0 ); +input_report_abs (sensors,ABS_RZ ,0 ); + +input_sync (sensors); + } +rcu_read_unlock (); }steam_haptic_pulse (steam,STEAM_PAD_RIGHT ,0x190 ,0 ,1 ,0 );
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v2 3/6] HID: steam: Fix wording of connect/disconnect logs
In reply to Vicki PfauThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Device sending an empty serial number causes silent resource leaks upon disconnection.
- [Medium] Registration failure leaves steam->serial_no populated, permanently breaking subsequent connections. --
--- Patch [3]: [PATCH v2 3/6] HID: steam: Fix wording of connect/disconnect logs --- commit 1846261fd57667e998e1416cd9dcdbedc57da4e8
Author: Vicki Pfau <[email protected]>
HID: steam: Fix wording of connect/disconnect logs
This commit updates the connect and disconnect log messages to properly identify the device as a Deck or a Controller depending on the device quirks. It aligns these messages with other special-cased strings in the driver.
drivers/hid/hid-steam.c static int steam_register(struct steam_device *steam) · line 1399
Quoted 12 lines
drivers/hid/hid-steam.c +2
-1@@ -1394,7 +1394,8 @@ static int steam_register(struct steam_device *steam)"%s:steam_get_attributes failed with error %d\n" , __func__, ret); -hid_info (steam->hdev,"Steam Controller '%s' connected" , +hid_info (steam->hdev,"Steam %s '%s' connected" , + steam->quirks &STEAM_QUIRK_DECK ?"Deck" :"Controller" , steam->serial_no);
[Severity: Medium]
This is a pre-existing issue, but can a registration failure permanently break subsequent connections for this device?
If steam_register() fails later in the function (for example, if steam_input_register() fails), the error path:
steam_register_sensors_fail:
steam_input_unregister(steam); steam_register_input_fail: steam_battery_unregister(steam); mutex_unlock(&steam->report_mutex); return ret;
cleans up resources but does not clear steam->serial_no.
On the next connection attempt, steam_register() will see steam->serial_no[0] is populated and immediately return 0 without setting up any input devices, leaving the device permanently broken until replugged.
drivers/hid/hid-steam.c static void steam_unregister(struct steam_device *steam) · line 1429
Quoted 5 lines
drivers/hid/hid-steam.c +0
-0/* ignore battery errors, we can live without it */ @@ -1427,7 +1428,8 @@ static void steam_unregister(struct steam_device *steam)if (!steam->serial_no[0 ])return ;
[Severity: High]
This is a pre-existing issue, but does this early return lead to a silent resource leak if the device sends an empty serial number?
If steam_get_serial() successfully reads a valid HID reply but the string payload is empty, it populates steam->serial_no with an empty string using strscpy() and returns success, bypassing the fallback serial generation.
Later, on disconnection, steam_unregister() will hit this early return and skip unregistering the input devices, sensors, and power supplies.
Quoted 7 lines
drivers/hid/hid-steam.c +2
-1-hid_info (steam->hdev,"Steam Controller '%s' disconnected" , +hid_info (steam->hdev,"Steam %s '%s' disconnected" , + steam->quirks &STEAM_QUIRK_DECK ?"Deck" :"Controller" , steam->serial_no);steam_battery_unregister (steam);steam_sensors_unregister (steam);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH v2 1/6] HID: steam: Unregister battery on partial registration error
In reply to Vicki PfauThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [Medium] Unregistering the battery in the error path prevents it from being re-registered on a subsequent retry of steam_register() because steam->serial_no[0] is not cleared.
Pre-existing issues:
- [High] The local variable do_add is conditionally initialized but unconditionally evaluated if steam_register() is called when steam->serial_no[0] is already set.
- [High] Teardown asymmetry in the steam_probe error path allows background work to register devices against a freed driver struct.
- [High] The unregister functions read RCU-protected pointers without writer-side serialization, leading to potential double-frees if executed concurrently. --
--- Patch [1]: [PATCH v2 1/6] HID: steam: Unregister battery on partial registration error --- commit 44ddde383b3d91088838e48fa3234971272a3bbc
Author: Vicki Pfau <[email protected]>
HID: steam: Unregister battery on partial registration error
This commit adds missing code to unregister the battery if later registration steps fail. This prevents a lingering power_supply object from being left over.
Quoted 4 lines
drivers/hid/hid-steam.c +0
-0
[ ... ]
drivers/hid/hid-steam.c static int steam_register(struct steam_device *steam) · line 1202
Quoted 5 lines
drivers/hid/hid-steam.c +1
-0@@ -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 prevent the battery from being re-registered on a subsequent retry?
If steam_register() fails, the error path now unregisters the battery. However, steam->serial_no[0] remains populated.
On a subsequent retry from steam_work_connect_cb(), the populated serial number bypasses the initialization block, skipping steam_battery_register().
drivers/hid/hid-steam.c static int steam_register(struct steam_device *steam) · line 1204
Quoted 2 lines
drivers/hid/hid-steam.c +0
-0return ret; }
While reviewing this, I noticed a few pre-existing issues:
drivers/hid/hid-steam.c:steam_register() {
bool do_add;
...
if (!steam->serial_no[0]) {
...
do_add = true;
}
...
if (do_add) {[Severity: High]
This is a pre-existing issue, but does this evaluate an uninitialized variable?
If steam_register() is called when steam->serial_no[0] is already populated, do_add is left uninitialized but is evaluated later in the function.
drivers/hid/hid-steam.c:steam_probe() {
...
err_steam_unregister:
if (steam->connected)
steam_unregister(steam);
err_hw_close:
hid_hw_close(hdev);
err_hw_stop:
hid_hw_stop(hdev);
err_cancel_work:
cancel_work_sync(&steam->work_connect);
...
}[Severity: High]
This is a pre-existing issue, but could this error path lead to a use-after-free?
If a wireless device schedules work_connect and probe fails, steam_unregister() is called before cancel_work_sync().
If work_connect hasn't initialized the device yet, steam_unregister() returns without effect. Then cancel_work_sync() waits for work_connect to finish, allowing it to register input devices against the steam driver struct which devres will free after probe returns.
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);
...
}[Severity: High]
This is a pre-existing issue, but can this lead to a double-free if executed concurrently?
The unregister functions read the RCU-protected pointers without writer-side serialization.
If steam_probe() error path calls steam_unregister() concurrently with work_connect() calling a failure path in steam_register(), both threads might read the same non-NULL pointer and concurrently free the same resources.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH v2 5/6] HID: steam: Clean up locking
In reply to Vicki PfauThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Guaranteed self-deadlock during device registration and unregistration due to recursive…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Guaranteed self-deadlock during device registration and unregistration due to recursive acquisition of steam->report_mutex. --
--- Patch [5]: [PATCH v2 5/6] HID: steam: Clean up locking --- commit f00f469b42e54055547cfa7401a79f8895766441
Author: Vicki Pfau <[email protected]>
HID: steam: Clean up locking
This cleans up several issues with locking behavior, including RCU accesses not being guarded behind a lock.
Quoted 4 lines
drivers/hid/hid-steam.c +0
-0
[ ... ]
drivers/hid/hid-steam.c static int steam_input_open(struct input_dev *dev) · line 925
Quoted 9 lines
drivers/hid/hid-steam.c +2
-2@@ -921,9 +920,10 @@ static int steam_input_open(struct input_dev *dev)*/ if (!(steam->quirks & (STEAM_QUIRK_DECK |STEAM_QUIRK_IBEX ))) {spin_lock_irqsave (&steam->lock, flags); - set_lizard_mode = !steam->client_opened && lizard_mode; + client_opened = steam->client_opened;spin_unlock_irqrestore (&steam->lock, flags); -if (set_lizard_mode) +guard (mutex)(&steam->report_mutex);
[Severity: High]
Does this create a self-deadlock during device registration?
When steam_register() is called, it now holds steam->report_mutex. It then calls steam_input_register(), which registers the input device. If an input handler (like ledtrig-input-events) is present, the input core will synchronously open the device, calling steam_input_open().
The call chain would look like:
steam_register()
mutex_lock(&steam->report_mutex); steam_input_register(steam);
input_register_device()
... (input core handler connect) input_open_device()
steam_input_open()
guard(mutex)(&steam->report_mutex); <-- deadlocks here
The same sequence applies during steam_unregister() when it calls steam_input_close() and steam_sensor_close().
Quoted 4 lines
drivers/hid/hid-steam.c +1
-0+if (!client_opened && lizard_mode)steam_set_lizard_mode (steam, false); }
[ ... ]
Quoted 8 lines
drivers/hid/hid-steam.c +1
-0@@ -1379,14 +1374,17 @@ static int steam_register(struct steam_device *steam) {int ret; +mutex_lock (&steam->report_mutex);/* * This function can be called several times in a row with the * wireless adaptor, without steam_unregister() between them, because
[ ... ]
Quoted 9 lines
drivers/hid/hid-steam.c +2
-0@@ -1439,9 +1439,11 @@ static void steam_unregister(struct steam_device *steam)hid_info (steam->hdev,"Steam %s '%s' disconnected" , steam->quirks &STEAM_QUIRK_DECK ?"Deck" :"Controller" , steam->serial_no); +mutex_lock (&steam->report_mutex);steam_battery_unregister (steam);steam_sensors_unregister (steam);steam_input_unregister (steam); +mutex_unlock (&steam->report_mutex);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH v2 2/6] HID: steam: Initial 2026 Steam Controller support
In reply to Vicki PfauThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [Medium] The removal of the explicit query workaround in steam_write_settings can cause driver initialization to fail on subsequent driver binds or module reloads due to lingering reports.
Pre-existing issues:
- [High] Use-After-Free due to HID events triggering work re-queuing during teardown because hid_hw_stop is called after cancel_work_sync.
- [High] Concurrent execution of steam_register leads to resource leaks and Use-After-Free/Double-Free on error paths due to missing locking.
- [High] Race condition in teardown functions (steam_battery_unregister, steam_input_unregister, etc.) leads to double-free of device components. --
--- Patch [2]: [PATCH v2 2/6] HID: steam: Initial 2026 Steam Controller support --- commit 4e3ca92dc2f8afcf2d70cdcfce3822923a4ccbfc
Author: Vicki Pfau <[email protected]>
HID: steam: Initial 2026 Steam Controller support
This brings support for the 2026 Steam Controller, comparably featureful to the existing support for the Steam Deck.
Quoted 4 lines
drivers/hid/hid-steam.c +0
-0
[ ... ]
Quoted 5 lines
drivers/hid/hid-steam.c +0
-1@@ -489,16 +615,7 @@ static int steam_write_settings(struct steam_device *steam, }va_end (args); - ret =steam_send_report (steam, cmd,2 + cmd[1 ]);
drivers/hid/hid-steam.c static int steam_write_settings(struct steam_device *steam, · line 618
Quoted 10 lines
drivers/hid/hid-steam.c +1
-9-if (ret <0 ) -return ret; - -/* -* Sometimes a lingering report for this command can -* get read back instead of the last set report if -* this isn't explicitly queried -*/ -return steam_recv_report (steam, cmd,2 + cmd[1 ]); +return steam_send_report (steam, cmd,2 + cmd[1 ]);
[Severity: Medium]
By removing the explicit steam_recv_report() call here, could a lingering report be left in the device buffer?
If the module is later reloaded or the driver rebound, steam_probe() will call steam_get_conn_status() which expects a wireless state report.
Quoted 1 line
drivers/hid/hid-steam.c +0
-0}
[ ... ]
Quoted 24 lines
drivers/hid/hid-steam.c +15
-7-/* -* This command requests the wireless adaptor to post an event -* with the connection status. Useful if this driver is loaded when -* the controller is already connected. -*/ -static inline int steam_request_conn_status (struct steam_device *steam) +static int steam_get_conn_status (struct steam_device *steam) { +int ret =0 ; +u8 cmd[] = {ID_DONGLE_GET_WIRELESS_STATE }; +u8 reply[3 ] = {}; +u8 report_id; + +if (steam->quirks &STEAM_QUIRK_IBEX ) + report_id =REPORT_ID_FEATURES_DONGLE ; +else + report_id =0 ; +guard (mutex)(&steam->report_mutex); -return steam_send_report_byte (steam,ID_DONGLE_GET_WIRELESS_STATE ); + ret =steam_send_report_id (steam, cmd,sizeof (cmd), report_id); +if (ret <0 ) +return ret; + ret =steam_recv_report_id (steam, reply,sizeof (reply), report_id);
drivers/hid/hid-steam.c static int steam_get_attributes(struct steam_device *steam) · line 737
Quoted 10 lines
drivers/hid/hid-steam.c +9
-0+if (ret <0 ) +return ret; +if (reply[0 ] !=ID_DONGLE_GET_WIRELESS_STATE || reply[1 ] <1 ) { +hid_err (steam->hdev,"%s: invalid reply (%*ph)\n" , __func__, + (int )sizeof (reply), reply); +return -EIO ; + } + +return reply[2 ]; }
[Severity: Medium]
Does this function read the lingering ID_SET_SETTINGS_VALUES report instead of the expected status?
Because this lacks a retry mechanism, it appears this would fail the reply[0] != ID_DONGLE_GET_WIRELESS_STATE check and return -EIO, breaking device initialization.
[ ... ]
Quoted 10 lines
drivers/hid/hid-steam.c +0
-6@@ -1149,51 +1377,42 @@ static int steam_register(struct steam_device *steam)* another client send a get_connection_status command, for example. * The battery and serial number are set just once per device. */ -if (!steam->serial_no[0 ]) { -/* -* Unlikely, but getting the serial could fail, and it is not so -* important, so make up a serial number and go on. -*/ -if (steam_get_serial (steam) <0 )
drivers/hid/hid-steam.c static int steam_register(struct steam_device *steam) · line 1381
Quoted 10 lines
drivers/hid/hid-steam.c +2
-8-strscpy (steam->serial_no,"XXXXXXXXXX" , -sizeof (steam->serial_no)); - - ret =steam_get_attributes (steam); -if (ret <0 ) -hid_err (steam->hdev, -"%s:steam_get_attributes failed with error %d\n" , - __func__, ret); +if (steam->serial_no[0 ]) +return 0 ;
[Severity: High]
This is a pre-existing issue, but does this check allow concurrent execution?
If a wireless connect event triggers steam_work_connect_cb() simultaneously with steam_probe() invoking steam_get_conn_status(), could both threads evaluate steam->serial_no[0] as empty because there is no locking here?
If so, both could proceed to allocate and register input devices and batteries.
Could this potentially overwrite the pointers and leak the first set, or cause a use-after-free when one thread fails and runs the error cleanup path on resources the other thread just allocated?
[ ... ]
drivers/hid/hid-steam.c static int steam_register(struct steam_device *steam) · line 1418
Quoted 13 lines
drivers/hid/hid-steam.c +4
-6-if (do_add) { -mutex_lock (&steam_devices_lock); -if (list_empty (&steam->list)) -list_add (&steam->list, &steam_devices); -mutex_unlock (&steam_devices_lock); - } +mutex_lock (&steam_devices_lock); +if (list_empty (&steam->list)) +list_add (&steam->list, &steam_devices); +mutex_unlock (&steam_devices_lock);return 0 ; steam_register_sensors_fail:
[Severity: High]
This is a pre-existing issue, but does the teardown sequence in steam_battery_unregister() and steam_input_unregister() have a race condition?
If these unregister functions are called concurrently (for example, if steam_register() fails on one thread while steam_work_connect_cb() processes a disconnect event on another), both threads could read the same component pointer within the RCU read-side critical section before either thread executes RCU_INIT_POINTER(..., NULL).
Would this cause both threads to call power_supply_unregister() and devm_kfree() on the exact same pointer, leading to a double-free?
[ ... ]
[Severity: High]
This is a pre-existing issue, but can the sequence in steam_remove() lead to a use-after-free?
drivers/hid/hid-steam.c:steam_remove() {
...
cancel_work_sync(&steam->work_connect);
...
hid_hw_stop(hdev);
}Because hid_hw_stop() is called after cancel_work_sync(), the HID transport can still deliver events during this window.
If an event like REPORT_ID_WIRELESS_EVENT arrives, steam_raw_event() will call steam_do_connect_event(), which calls schedule_work(&steam->work_connect), re-queuing the work after it was cancelled.
Once steam_remove() returns and devres frees the steam_device structure, will the workqueue run steam_work_connect_cb() on the freed memory?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2