Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Derek J. Clark" <derekjohn.clark@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 06/10] HID: hid-lenovo-go-s: Add suspend function and gate access under bool.
Date: Mon, 14 Sep 2026 23:31:56 +0000	[thread overview]
Message-ID: <20260914233157.144B31F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914225303.868569-7-derekjohn.clark@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] hid: hid-lenovo-go-s: Suspend callback permanently disables setup work, breaking resume
- [Medium] hid: hid-lenovo-go-s: Transient MCU query failures permanently lock out sysfs configuration
--

commit 4cf4113a0e592276fc9988337678d1232b964a33
Author: Derek J. Clark <derekjohn.clark@gmail.com>

HID: hid-lenovo-go-s: Add suspend function and gate access under bool.

This commit adds a suspend function to cancel pending delayed work during
system sleep. It also introduces boolean flags to prevent sysfs attribute
access prior to the configuration setup completing.

> diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
> index 712823e22beae..6d98fff6d987e 100644
> --- a/drivers/hid/hid-lenovo-go-s.c
> +++ b/drivers/hid/hid-lenovo-go-s.c

[ ... ]

>  static void cfg_setup(struct work_struct *work)
>  {
>  	int ret;
>  
>  	/* MCU */
>  	ret = mcu_property_out(drvdata.hdev, GET_MCU_ID, FEATURE_NONE, NULL, 0);
>  	if (ret) {
>  		dev_err(&drvdata.hdev->dev, "Failed to retrieve MCU ID: %i\n",
>  			ret);
>  		return;

[Severity: Medium]
If one of these initial MCU queries fails due to a transient error or timeout,
does this early return prevent the gp_registered and rgb_registered flags from
ever being set? Since there is no retry mechanism here, this could leave the
sysfs configuration permanently returning -ENODEV until the device is
replugged.

>  	}

[ ... ]

>  static int hid_gos_cfg_reset_resume(struct hid_device *hdev)
>  {
> +	bool gp_registered, rgb_registered;
>  	u8 os_mode = drvdata.os_mode;
>  	int ret;
>  
> +	/* Pairs with smp_store_release from gos_cfg_setup */
> +	gp_registered = smp_load_acquire(&drvdata.gp_registered);
> +	/* Pairs with smp_store_release from gos_cfg_setup */
> +	rgb_registered = smp_load_acquire(&drvdata.rgb_registered);
> +	if (!gp_registered || !rgb_registered) {
> +		ret = schedule_delayed_work(&drvdata.gos_cfg_setup, msecs_to_jiffies(2));
> +		if (!ret) {
> +			dev_err(&hdev->dev, "Failed to schedule startup delayed work\n");
> +			return -ENODEV;
> +		}
> +
> +		return 0;
> +	}

[ ... ]

> +static int hid_gos_cfg_suspend(void)
> +{
> +	disable_delayed_work_sync(&drvdata.gos_cfg_setup);

[Severity: High]
Does using disable_delayed_work_sync() here permanently disable the work
queue since there is no matching enable_delayed_work() call?

If the work queue is permanently disabled, schedule_delayed_work() in
hid_gos_cfg_reset_resume() will return false. Would treating a false return
from schedule_delayed_work() as a fatal error cause the resume operation to
abort unconditionally with -ENODEV?

Could cancel_delayed_work_sync() be used instead to cancel the work without
disabling it?

> +
> +	return 0;
> +}

[ ... ]

While looking at this driver, I noticed a pre-existing issue in
hid_gos_probe():

>  static int hid_gos_probe(struct hid_device *hdev,
>  			 const struct hid_device_id *id)
>  {
[ ... ]
>  	ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
>  	if (ret) {
>  		hid_err(hdev, "Failed to start HID device\n");
>  		return ret;
>  	}
>  
>  	ret = hid_hw_open(hdev);
>  	if (ret) {
>  		hid_err(hdev, "Failed to open HID device\n");
>  		hid_hw_stop(hdev);
>  		return ret;
>  	}
>  
>  	ep = get_endpoint_address(hdev);
>  	if (ep != GO_S_CFG_INTF_IN) {
>  		dev_dbg(&hdev->dev, "Started interface %x as generic HID device.\n", ep);
>  		return 0;
>  	}
>  
>  	ret = hid_gos_cfg_probe(hdev, id);
>  	if (ret)
>  		dev_err_probe(&hdev->dev, ret, "Failed to start configuration interface");
>  
>  	dev_dbg(&hdev->dev, "Started interface %x as Go S configuration interface\n", ep);
>  	return ret;
>  }

[Severity: High]
This isn't a bug introduced by this patch, but if hid_gos_cfg_probe() fails,
does this error path return without calling hid_hw_stop() and hid_hw_close()?
This would leave the hardware active and leak resources since the HID core
does not automatically invoke the .remove() callback on a probe failure.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260914225303.868569-1-derekjohn.clark@gmail.com?part=6

  reply	other threads:[~2026-09-14 23:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 22:52 [PATCH 00/10] HID: hid-lenovo-go-s: Fix various bugs Derek J. Clark
2026-09-14 22:52 ` [PATCH 01/10] HID: hid-lenovo-go-s: Return ret instead of 0 in mcu_property_out() Derek J. Clark
2026-09-14 22:52 ` [PATCH 02/10] HID: hid-lenovo-go-s: Bound stale reply window before reusing send_cmd_complete Derek J. Clark
2026-09-14 23:26   ` sashiko-bot
2026-09-14 22:52 ` [PATCH 03/10] HID: hid-lenovo-go-s: Prevent deadlock if device removed during setup Derek J. Clark
2026-09-14 23:28   ` sashiko-bot
2026-09-14 22:52 ` [PATCH 04/10] HID: hid-lenovo-go-s: Use pm_ptr for reset_resume callback Derek J. Clark
2026-09-14 22:52 ` [PATCH 05/10] HID: hid-lenovo-go-s: Add kobject_uevent notify during reset-resume Derek J. Clark
2026-09-14 22:52 ` [PATCH 06/10] HID: hid-lenovo-go-s: Add suspend function and gate access under bool Derek J. Clark
2026-09-14 23:31   ` sashiko-bot [this message]
2026-09-14 22:53 ` [PATCH 07/10] HID: hid-lenovo-go-s: Move attribute init to after device query Derek J. Clark
2026-09-14 23:30   ` sashiko-bot
2026-09-14 22:53 ` [PATCH 08/10] HID: hid-lenovo-go-s: Reorganize and rename hid_gos_cfg Derek J. Clark
2026-09-14 22:53 ` [PATCH 09/10] HID: hid-lenovo-go-s: Move static led_classdev_mc to drvdata struct Derek J. Clark
2026-09-14 22:53 ` [PATCH 10/10] HID: hid-lenovo-go-s: Use devm_kzalloc for drvdata Derek J. Clark

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=20260914233157.144B31F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=derekjohn.clark@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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