]> git.hungrycats.org Git - linux/commitdiff
HID: hid-lenovo-go-s: Return ret instead of 0 in mcu_property_out()
authorDerek J. Clark <derekjohn.clark@gmail.com>
Mon, 14 Sep 2026 22:52:54 +0000 (15:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:51 +0000 (12:10 -0500)
commit 8ac42b2885322dc7fb03d88c5411e9dbd24f80d9 upstream.

Currently mcu_property_out() blanket returns 0, discarding the ret
value and any errors with it. Wait completion returns a positive value
when it is not timed out, which would error on all successes, so if it
is positive return the ret value from the raw event handler. Only if
it is 0 set it to -EBUSY, otherwise pass the actual error.

Fixes: a23f3497bf208c59ad ("HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/hid-lenovo-go-s.c

index bf4e500b8ace2fe7f4e39364f7b2ba320ee77d32..fd9a80b15209ab2a7d08a1574ace943ada8c084d 100644 (file)
@@ -38,6 +38,7 @@ static struct hid_gos_cfg {
        struct led_classdev *led_cdev;
        struct hid_device *hdev;
        struct mutex cfg_mutex; /*ensure single synchronous output report*/
+       int cmd_status;
        u8 gp_auto_sleep_time;
        u8 gp_dpad_mode;
        u8 gp_mode;
@@ -435,7 +436,9 @@ static int hid_gos_raw_event(struct hid_device *hdev, struct hid_report *report,
        dev_dbg(&hdev->dev, "Rx data as raw input report: [%*ph]\n",
                GO_S_PACKET_SIZE, data);
 
+       drvdata.cmd_status = ret;
        complete(&drvdata.send_cmd_complete);
+
        return ret;
 }
 
@@ -474,12 +477,10 @@ static int mcu_property_out(struct hid_device *hdev, u8 command, u8 index,
        timeout = (command == GET_PL_TEST) ? 200 : 5;
        ret = wait_for_completion_interruptible_timeout(&drvdata.send_cmd_complete,
                                                        msecs_to_jiffies(timeout));
-
-       if (ret == 0) /* timeout occurred */
-               ret = -EBUSY;
+       ret = ret > 0 ? drvdata.cmd_status : ret ?: -EBUSY;
 
        reinit_completion(&drvdata.send_cmd_complete);
-       return 0;
+       return ret;
 }
 
 static ssize_t gamepad_property_store(struct device *dev,