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 v14 11/18] HID: asus: add support for turbo buttons
Date: Fri, 06 Nov 2026 14:42:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-201599@kernel.org> (raw)
In-Reply-To: <20261106142334.1881-12-denis.benato@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] HID: asus: mix of cleanup helpers and goto in
ally_create_button_attributes()
- [Low] HID: asus: per-call stack lookup table in ally_btn_param()
--
commit 41d2b47a8b98d8711a6cf26beaa8f9fb7b5092d2
Author: Denis Benato <denis.benato@linux.dev>
HID: asus: add support for turbo buttons
This commit adds sysfs attributes to configure per-button turbo and toggle
periods on ROG Ally devices and restores those parameters on device
initialization.
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index cf33ccefcc2b3..c0c337a5fcba9 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> @@ -2143,8 +2222,261 @@ static const struct attribute_group ally_attr_groups[] = {
> },
> };
>
> +static struct ally_btn_turbo_params *ally_btn_param(enum ally_button_id btn)
> +{
> + struct ally_btn_turbo_params *table[ALLY_BTN_MAX] = {
> + [ALLY_BTN_A] = &ally_prefs.turbo.btn_a,
> + [ALLY_BTN_B] = &ally_prefs.turbo.btn_b,
> + [ALLY_BTN_X] = &ally_prefs.turbo.btn_x,
> + [ALLY_BTN_Y] = &ally_prefs.turbo.btn_y,
> + [ALLY_BTN_LB] = &ally_prefs.turbo.btn_lb,
> + [ALLY_BTN_RB] = &ally_prefs.turbo.btn_rb,
> + [ALLY_BTN_DU] = &ally_prefs.turbo.btn_du,
> + [ALLY_BTN_DD] = &ally_prefs.turbo.btn_dd,
> + [ALLY_BTN_DL] = &ally_prefs.turbo.btn_dl,
> + [ALLY_BTN_DR] = &ally_prefs.turbo.btn_dr,
> + [ALLY_BTN_J0B] = &ally_prefs.turbo.btn_j0b,
> + [ALLY_BTN_J1B] = &ally_prefs.turbo.btn_j1b,
> + [ALLY_BTN_MENU] = &ally_prefs.turbo.btn_menu,
> + [ALLY_BTN_VIEW] = &ally_prefs.turbo.btn_view,
> + [ALLY_BTN_M1] = &ally_prefs.turbo.btn_m1,
> + [ALLY_BTN_M2] = &ally_prefs.turbo.btn_m2,
> + };
> +
> + if (btn >= ALLY_BTN_MAX)
> + return NULL;
> +
> + return table[btn];
> +}
[Severity: Low]
This isn't a bug, but table[] holds fixed pointers into the static
ally_prefs.turbo struct and is rebuilt on the stack on every call. Could it
be declared static const like the other lookup tables in this file?
[ ... ]
> +static struct ally_btn_sysfs_entry *ally_create_button_attributes(struct hid_device *hdev)
> +{
> + int i, ret;
> +
> + scoped_guard(mutex, &ally_prefs.lock)
> + if (!ally_prefs.turbo_support)
> + return NULL;
> +
> + struct ally_btn_sysfs_entry *entries __free(kfree) = kzalloc_objs(*entries, ALLY_BTN_MAX);
> + if (!entries)
> + return ERR_PTR(-ENOMEM);
> +
> + for (i = 0; i < ALLY_BTN_MAX; i++) {
> + entries[i].btn = i;
> +
> + if (!ally_btn_param(i)) {
> + hid_err(hdev, "Invalid button id %d for turbo attributes\n", i);
> + ret = -EINVAL;
> + goto ally_btn_err_cleanup;
> + }
> +
> + ally_btn_turbo_init_attrs(&entries[i]);
> + entries[i].group.name = ally_button_names[i];
> + entries[i].group.attrs = entries[i].attrs;
> +
> + ret = sysfs_create_group(&hdev->dev.kobj, &entries[i].group);
> + if (ret < 0) {
> + hid_err(hdev, "Failed to create sysfs group for %s: %d\n",
> + ally_button_names[i], ret);
> + goto ally_btn_err_cleanup;
> + }
> + }
> +
> + return no_free_ptr(entries);
> +
> +ally_btn_err_cleanup:
> + while (i--)
> + sysfs_remove_group(&hdev->dev.kobj, &entries[i].group);
> +
> + return ERR_PTR(ret);
> +}
[Severity: Low]
This isn't a bug, but ally_create_button_attributes() mixes __free(kfree)
with goto ally_btn_err_cleanup, contrary to the cleanup.h guideline against
combining scope-based cleanup helpers and goto error handling in the same
function. Since ally_btn_err_cleanup already unwinds the loop on failure,
entries could be freed explicitly with kfree(entries) there instead of using
__free(kfree) and no_free_ptr().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106142334.1881-1-denis.benato@linux.dev?part=11
next prev parent reply other threads:[~2026-11-06 14:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 14:23 [PATCH v14 00/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-11-06 14:23 ` [PATCH v14 01/18] HID: asus: size feature reports from the HID report descriptor Denis Benato
2026-11-06 14:51 ` sashiko-bot
2026-11-06 14:23 ` [PATCH v14 02/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-11-06 14:51 ` sashiko-bot
2026-11-06 14:23 ` [PATCH v14 03/18] HID: asus: add gamepad configuration Denis Benato
2026-11-06 14:23 ` [PATCH v14 04/18] HID: asus: add vibration strength configuration Denis Benato
2026-11-06 14:23 ` [PATCH v14 05/18] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-11-06 14:23 ` [PATCH v14 06/18] HID: asus: add triggers " Denis Benato
2026-11-06 14:23 ` [PATCH v14 07/18] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-11-06 14:23 ` [PATCH v14 08/18] HID: asus: add support for response curve Denis Benato
2026-11-06 14:23 ` [PATCH v14 09/18] HID: asus: add support to force feedback Denis Benato
2026-11-06 14:23 ` [PATCH v14 10/18] HID: asus: add support for gamepad mode Denis Benato
2026-11-06 14:23 ` [PATCH v14 11/18] HID: asus: add support for turbo buttons Denis Benato
2026-11-06 14:42 ` sashiko-bot [this message]
2026-11-06 14:23 ` [PATCH v14 12/18] HID: asus: add support for btn remapping Denis Benato
2026-11-06 14:46 ` sashiko-bot
2026-11-06 14:23 ` [PATCH v14 13/18] HID: asus: identify XG Mobile stations and bind the LED to the reported model Denis Benato
2026-11-06 14:23 ` [PATCH v14 14/18] HID: asus: expose XG Mobile identity and firmware information Denis Benato
2026-11-06 14:23 ` [PATCH v14 15/18] HID: asus: document ROG XG Mobile sysfs attributes Denis Benato
2026-11-06 14:23 ` [PATCH v14 16/18] HID: asus: document ROG Ally " Denis Benato
2026-11-06 14:23 ` [PATCH v14 17/18] platform/x86: asus-armoury: pick the eGPU activation from the reported GPU Denis Benato
2026-11-06 14:23 ` [PATCH v14 18/18] MAINTAINERS: add maintainer for the ASUS HID driver Denis Benato
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=sashiko-outbox-201599@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.