Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Denis Benato" <denis.benato@linux.dev>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 3/3] HID: asus: add support for xgm led
Date: Tue, 15 Sep 2026 18:19:00 +0000	[thread overview]
Message-ID: <20260915181901.5393D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260915181200.18086-4-denis.benato@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hid: asus: I/O on stopped device in probe error path
--

commit d32c2e222ce9fd06cb5cc60459d66b339dbd284d
Author: Denis Benato <denis.benato@linux.dev>

HID: asus: add support for xgm led

This commit adds an LED class device interface to control the brightness
of the red LEDs on Asus XG mobile stations. It registers the LED using
the managed devm_led_classdev_register API and hooks up a callback to
set the brightness via HID reports.

> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index e6218abdac49c..825833f6c2c4d 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c

[ ... ]

> @@ -1545,6 +1616,16 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  	if (!drvdata->tp)
>  		asus_initialize_reports(hdev);
>  
> +	if (asus_has_report_id(hdev, FEATURE_KBD_REPORT_ID) &&
> +	    ((hdev->product == USB_DEVICE_ID_ASUSTEK_XGM_2022) ||
> +	     (hdev->product == USB_DEVICE_ID_ASUSTEK_XGM_2023))) {
> +		ret = asus_xgm_init(hdev, drvdata);
> +		if (ret) {
> +			hid_err(hdev, "Failed to initialize xg mobile: %d\n", ret);
> +			goto err_stop_hw;
> +		}
> +	}
> +

[Severity: High]
Does the err_stop_hw path in asus_probe() need to manually unregister the
xgm_led before stopping the hardware?

If probe fails after asus_xgm_init() successfully registers the LED (for
example, if asus_start_multitouch() fails later in the probe function),
the execution jumps to err_stop_hw:

err_stop_hw:
	if (drvdata->listener.brightness_set)
		asus_hid_unregister_listener(&drvdata->listener);

	asus_worker_stop(drvdata->worker);
	hid_hw_stop(hdev);
	return ret;

Since the LED was registered with devm_led_classdev_register(), devres
will automatically unregister it when asus_probe() returns. However,
unregistering an LED classdev natively turns it off, invoking the
blocking asus_xgm_led_set() callback.

Because hid_hw_stop() has already shut down the hardware in this path,
asus_xgm_led_set() will call hid_hw_raw_request() on a stopped (and
potentially partially freed) HID transport. Depending on the lower-level
driver, this can lead to a use-after-free or a kernel crash.

I see this is handled safely in asus_remove() by explicitly unregistering
the LED before hid_hw_stop() is called. Could we do the same in the probe
error path?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260915181200.18086-1-denis.benato@linux.dev?part=3

  reply	other threads:[~2026-09-15 18:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 18:11 [PATCH 0/3] HID: asus: improve the driver support for laptops Denis Benato
2026-09-15 18:11 ` [PATCH 1/3] HID: asus: document and harden the worker teardown Denis Benato
2026-09-15 18:11 ` [PATCH 2/3] HID: asus: reinitialize the device after exiting a sleep state Denis Benato
2026-09-15 18:12 ` [PATCH 3/3] HID: asus: add support for xgm led Denis Benato
2026-09-15 18:19   ` sashiko-bot [this message]
2026-09-15 21:52   ` Antheas Kapenekakis
2026-09-16  0:54     ` Denis Benato
2026-09-16  6:46       ` Antheas Kapenekakis
2026-09-16 12:18         ` Denis Benato
2026-09-16 12:31           ` Antheas Kapenekakis
2026-09-16 13:05             ` Denis Benato
2026-09-17 22:06               ` Antheas Kapenekakis
2026-09-18  1:50                 ` Denis Benato
2026-09-18  7:28                   ` Antheas Kapenekakis
2026-09-18  7:29                     ` Antheas Kapenekakis

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=20260915181901.5393D1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=denis.benato@linux.dev \
    --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