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 06/12] HID: asus: add triggers inner and outer range configuration
Date: Thu, 13 Aug 2026 14:58:59 +0000 [thread overview]
Message-ID: <20260813145859.C77691F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813144736.2477941-7-denis.benato@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Time-of-check to time-of-use (TOCTOU) race condition in trigger threshold sysfs stores causes hardware state desynchronization.
Pre-existing issues:
- [High] The `config_mutex` in `struct ally_config` is dynamically allocated but never explicitly initialized.
--
--- Patch [6]: [PATCH 06/12] HID: asus: add triggers inner and outer range configuration ---
commit bf1ab6fc2d6df4d87a7b2cef0f0cf8628bb2f010
Author: Denis Benato <denis.benato@linux.dev>
HID: asus: add triggers inner and outer range configuration
This patch adds sysfs attributes to configure the inner and outer ranges for
the left and right triggers on ROG Ally devices. It implements the store and
show functions for these limits and sends the updated configuration to the
hardware.
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 010b33533068a..eb735ec8f065c 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> +static ssize_t left_trigger_range_lower_limit_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct hid_device *hdev = to_hid_device(dev);
> + struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
> + struct ally_handheld *const ally = drvdata->rog_ally;
> + u8 value;
> + int ret;
> +
> + if (!ally || !ally->config)
> + return -ENODEV;
> +
> + ret = kstrtou8(buf, 10, &value);
> + if (ret || value > 50)
> + return -EINVAL;
> +
> + ret = ally_set_trigger_ranges(hdev, ally->config,
> + value,
> + ally->config->left_trigger_max,
> + ally->config->right_trigger_min,
> + ally->config->right_trigger_max);
[Severity: Medium]
Could this cause a TOCTOU data race if multiple threads write to the trigger
sysfs attributes concurrently?
Since the other limit values are read locklessly from `ally->config` before the
hardware is updated, concurrent writes to different attributes could interleave.
This might result in one thread sending a stale limit while overwriting the
other thread's hardware update, permanently desynchronizing the hardware
configuration from the driver's software cache.
Should the mutex be acquired before calling `ally_set_trigger_ranges()`?
> + if (ret)
> + return ret;
> +
> + scoped_guard(mutex, &ally->config->config_mutex)
> + ally->config->left_trigger_min = value;
> +
> + return count;
> +}
[ ... ]
> @@ -1246,6 +1540,10 @@ static struct ally_config *ally_config_create(struct hid_device *hdev, struct al
> cfg->left_outer_threshold = 90;
> cfg->right_deadzone = 10;
> cfg->right_outer_threshold = 90;
> + cfg->left_trigger_min = 0;
> + cfg->left_trigger_max = 100;
> + cfg->right_trigger_min = 0;
> + cfg->right_trigger_max = 100;
[Severity: High]
This is a pre-existing issue, but is `config_mutex` ever explicitly initialized?
In `ally_config_create()`, `cfg` is dynamically allocated via `devm_kzalloc()`
which zero-initializes the memory. However, it appears
`mutex_init(&cfg->config_mutex)` is never called before the mutex is locked in
functions like `ally_detect_capabilities()` or the sysfs store operations.
Could this lead to a kernel panic or lockdep warning when the uninitialized
mutex is locked under contention?
> cfg->vibration_intensity_left = 100;
> cfg->vibration_intensity_right = 100;
> cfg->vibration_active = false;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260813144736.2477941-1-denis.benato@linux.dev?part=6
next prev parent reply other threads:[~2026-08-13 14:59 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 14:47 [PATCH 00/12] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-08-13 14:47 ` [PATCH 01/12] HID: asus: reinitialize the device after exiting a sleep state Denis Benato
2026-08-13 14:55 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 02/12] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-08-13 15:00 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 03/12] HID: asus: add gamepad configuration Denis Benato
2026-08-13 14:59 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 04/12] HID: asus: add vibration strength configuration Denis Benato
2026-08-13 14:56 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 05/12] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-08-13 15:02 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 06/12] HID: asus: add triggers " Denis Benato
2026-08-13 14:58 ` sashiko-bot [this message]
2026-08-13 14:47 ` [PATCH 07/12] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-08-13 15:02 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 08/12] HID: asus: add support for response curve Denis Benato
2026-08-13 14:59 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 09/12] HID: asus: add support to force feedback Denis Benato
2026-08-13 15:10 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 10/12] HID: asus: add support for gamepad mode Denis Benato
2026-08-13 15:10 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 11/12] HID: asus: add support for turbo buttons Denis Benato
2026-08-13 15:10 ` sashiko-bot
2026-08-13 14:47 ` [PATCH 12/12] HID: asus: add support for btn remapping Denis Benato
2026-08-13 15:12 ` sashiko-bot
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=20260813145859.C77691F000E9@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