From: sashiko-bot@kernel.org
To: "Denis Benato" <denis.benato@linux.dev>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 08/12] HID: asus: add support for response curve
Date: Thu, 13 Aug 2026 14:59:46 +0000 [thread overview]
Message-ID: <20260813145947.671521F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813144736.2477941-9-denis.benato@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Missing NULL pointer checks in sysfs callbacks cause a reliable kernel panic during device probe (NULL pointer dereference).
--
--- Patch [8]: [PATCH 08/12] HID: asus: add support for response curve ---
commit 6ba0f4853fce7434b3f1730f265395260f85991d
Author: Denis Benato <denis.benato@linux.dev>
Subject: HID: asus: add support for response curve
This commit adds support for configuring the joystick response curves on ROG
ally devices. It introduces several sysfs attributes that allow userspace to
modify the response curve parameters.
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 8ed10c5b22ab5..8018e61cf0264 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> @@ -1584,6 +1607,319 @@ static struct device_attribute dev_attr_right_trigger_range_upper_limit =
> static struct device_attribute dev_attr_right_trigger_range_upper_limit_range =
> __ATTR(range_upper_limit_range, 0444, right_trigger_range_upper_limit_range_show, NULL);
>
> +enum ally_joystick_side {
> + JOYSTICK_LEFT = 0,
> + JOYSTICK_RIGHT,
> +};
> +
[ ... ]
> +static int response_curve_apply(struct hid_device *hdev, bool is_left)
> +{
> + struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
> + struct ally_handheld *const ally = drvdata->rog_ally;
> + struct ally_config *cfg = ally->config;
[Severity: Critical]
Could ally->config become NULL here if the device is concurrently unbound?
The check for !ally || !ally->config happens in
left_response_curve_apply_store and right_response_curve_apply_store before
calling this function, but it is performed outside of any lock. Could this
lead to a NULL pointer dereference if the state changes in between?
> + struct ally_joystick_resp_curve curve;
> + int ret;
> +
> + /*
> + * Snapshot under the lock so a concurrent sysfs write cannot change an
> + * entry between the monotonicity check and the packet being built.
> + */
> + scoped_guard(mutex, &cfg->config_mutex)
> + curve = is_left ? cfg->left_curve : cfg->right_curve;
> +
[ ... ]
> +#define DEFINE_JS_CURVE_PCT_FOPS(region, side) \
> + static ssize_t side##_response_curve_pct_##region##_show( \
> + struct device *dev, struct device_attribute *attr, char *buf) \
> + { \
> + struct hid_device *hdev = to_hid_device(dev); \
> + struct asus_drvdata *drvdata = hid_get_drvdata(hdev); \
> + struct ally_handheld *ally = drvdata->rog_ally; \
> + return response_curve_pct_show( \
> + dev, attr, buf, &ally->config->side##_curve, region);\
> + } \
[Severity: Critical]
Can ally or ally->config be NULL here when userspace (like udev) reads
these sysfs attributes during device probe?
If they are accessed before drvdata->rog_ally is fully populated, would
&ally->config->side##_curve cause a NULL pointer dereference? The older
sysfs attributes appear to include an if (!ally || !ally->config) check
before dereferencing these.
> + \
> + static ssize_t side##_response_curve_pct_##region##_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 *ally = drvdata->rog_ally; \
> + return response_curve_pct_store(dev, attr, buf, count, \
> + side##_is_left, ally, region); \
> + }
> +
> +#define DEFINE_JS_CURVE_MOVE_FOPS(region, side) \
> + static ssize_t side##_response_curve_move_##region##_show( \
> + struct device *dev, struct device_attribute *attr, char *buf) \
> + { \
> + struct hid_device *hdev = to_hid_device(dev); \
> + struct asus_drvdata *drvdata = hid_get_drvdata(hdev); \
> + struct ally_handheld *ally = drvdata->rog_ally; \
> + return response_curve_move_show( \
> + dev, attr, buf, &ally->config->side##_curve, region);\
> + } \
[Severity: Critical]
Does this also need a check to prevent a NULL pointer dereference if ally or
ally->config are accessed during probe?
> + \
> + static ssize_t side##_response_curve_move_##region##_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 *ally = drvdata->rog_ally; \
> + return response_curve_move_store(dev, attr, buf, count, \
> + side##_is_left, ally, region); \
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260813144736.2477941-1-denis.benato@linux.dev?part=8
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
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 [this message]
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=20260813145947.671521F000E9@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