Skip to contentSkip to conversation

HID: lenovo-go: Fix reset_tx_dongle sysfs attribute to be write-only

PATCH In review Ian Rogers 2 participants 2 messages Nov 19 – Nov 23

Subsystems (2)
lore
Share & tools
lore

Ian Rogers

author
#0 lore raw

PATCH 1/1 HID: lenovo-go: Fix reset_tx_dongle sysfs attribute to be write-only

reset_tx_dongle is defined with LEGO_DEVICE_ATTR_RO(), whereas all other FEATURE_RESET_GAMEPAD attributes in hid-lenovo-go.c (reset_mcu, reset_left, and reset_right) use LEGO_DEVICE_ATTR_WO().

Because feature_status_show() has no case for FEATURE_RESET_GAMEPAD (which is only handled in feature_status_store()), exposing tx_dongle's reset attribute as read-only makes reading it always fail with -EINVAL while preventing userspace from writing to it to reset the TX dongle.

Change reset_tx_dongle to LEGO_DEVICE_ATTR_WO().

Found by enabling Clang's -Wswitch-enum on an x86_64 allyesconfig build, with AI coding assistant help to audit the warning and prepare the fix. Build-tested with Clang; not runtime-tested on Lenovo Legion Go hardware.

Fixes 82cd9bc866e1 ("HID: hid-lenovo-go: Add Feature Status Attributes")
---
 drivers/hid/hid-lenovo-go.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-lenovo-go.c +1 -1
index 318b1152ff8b..8a2aa2b4825d 100644
@@ -1848,7 +1848,7 @@ static struct go_cfg_attr version_gen_tx_dongle = { HARDWARE_GENERATION };
 LEGO_DEVICE_ATTR_RO(version_gen_tx_dongle, "hardware_generation", TX_DONGLE, version);
 
 static struct go_cfg_attr reset_tx_dongle = { FEATURE_RESET_GAMEPAD };
-LEGO_DEVICE_ATTR_RO(reset_tx_dongle, "reset", TX_DONGLE, feature_status);
+LEGO_DEVICE_ATTR_WO(reset_tx_dongle, "reset", TX_DONGLE, feature_status);
 
 static struct attribute *tx_dongle_attrs[] = {
 	&dev_attr_reset_tx_dongle.attr,
Signature · 1 line
2.56.1.708.g77570a6a1d-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Ian Rogers

reset_tx_dongle is defined with LEGO_DEVICE_ATTR_RO(), whereas all other FEATURE_RESET_GAMEPAD attributes in hid-lenovo-go.c (reset_mcu, reset_left, and reset_right) use LEGO_DEVICE_ATTR_WO().

Because feature_status_show() has no case for FEATURE_RESET_GAMEPAD (which is only handled in feature_status_store()), exposing tx_dongle's reset attribute as read-only makes reading it always fail with -EINVAL while preventing userspace from writing to it to reset the TX dongle.

Change reset_tx_dongle to LEGO_DEVICE_ATTR_WO().

Found by enabling Clang's -Wswitch-enum on an x86_64 allyesconfig build, with AI coding assistant help to audit the warning and prepare the fix. Build-tested with Clang; not runtime-tested on Lenovo Legion Go hardware.

Fixes 82cd9bc866e1 ("HID: hid-lenovo-go: Add Feature Status Attributes")
---
 drivers/hid/hid-lenovo-go.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-lenovo-go.c +1 -1
index 318b1152ff8b..8a2aa2b4825d 100644
@@ -1848,7 +1848,7 @@ static struct go_cfg_attr version_gen_tx_dongle = 
 { HARDWARE_GENERATION };
 LEGO_DEVICE_ATTR_RO(version_gen_tx_dongle, "hardware_generation", 
 TX_DONGLE, version);
 
 static struct go_cfg_attr reset_tx_dongle = { FEATURE_RESET_GAMEPAD };
-LEGO_DEVICE_ATTR_RO(reset_tx_dongle, "reset", TX_DONGLE, feature_status);
+LEGO_DEVICE_ATTR_WO(reset_tx_dongle, "reset", TX_DONGLE, feature_status);
 
Quoted 4 lines

static struct attribute *tx_dongle_attrs[] = {
&dev_attr_reset_tx_dongle.attr,

Signature · 1 line
2.56.1.708.g77570a6a1d-goog

This looks good to me

Mark