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 12/18] HID: asus: add support for btn remapping
Date: Fri, 06 Nov 2026 14:46:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-201604@kernel.org> (raw)
In-Reply-To: <20261106142334.1881-13-denis.benato@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] HID: asus: mixed cleanup helpers and goto in
button_remap_store()
--
commit 0fe51bd4cd86b318227ccb9c127184422216243c
Author: Denis Benato <denis.benato@linux.dev>
HID: asus: add support for btn remapping
This commit adds sysfs attributes and firmware command support for button
and macro remapping on ASUS ROG Ally handheld devices.
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index c0c337a5fcba9..cb6c55e75e6ee 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> +static ssize_t button_remap_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct hid_device *hdev = to_hid_device(dev);
> + struct button_remap_attr *btn_attr = to_button_remap_attr(attr);
> + enum ally_button_id button_id = btn_attr->button_id;
> + const struct btn_code_map *old_code, *code;
> + const struct btn_code_map **target_map;
> + struct ally_button_mapping *mode_map;
> + enum btn_pair_index pair_idx;
> + struct button_pair_map *pair;
> + struct button_map *btn_map;
> + bool is_first;
> + int ret, i;
> +
> + code = find_button_by_name(buf);
> + if (!code)
> + return -EINVAL;
> +
> + ret = get_button_pair_info(button_id, &pair_idx, &is_first);
> + if (ret < 0)
> + return ret;
> +
> + guard(mutex)(&ally_prefs.lock);
> +
> + /*
> + * Validate the remap target while holding the lock: the
> + * gamepad mode can change concurrently, and the check must
> + * be done against the very mode the mapping is written to.
> + */
> + if (!ally_remap_code_valid(button_id, ally_prefs.gamepad_mode, code,
> + btn_attr->is_macro))
> + return -EINVAL;
> +
> + /* Access the mapping for current gamepad mode */
> + pair = &ally_prefs.button_mappings.button_pairs[pair_idx - 1];
> + btn_map = is_first ? &pair->first : &pair->second;
> +
> + target_map = btn_attr->is_macro ? &btn_map->macro : &btn_map->remap;
> + old_code = *target_map;
> + *target_map = code;
> +
> + /* Update pair index */
> + pair->pair_index = pair_idx;
> +
> + /*
> + * Send mapping to device with the caveat that first
> + * generation devices require individual button pair updates.
> + */
> + if (ally_prefs.is_ally_x) {
> + ret = ally_set_button_mapping(hdev, pair);
> + if (ret < 0)
> + goto err_restore;
> + } else {
> + mode_map = &ally_prefs.button_mappings;
> + for (i = 0; i < ARRAY_SIZE(mode_map->button_pairs); i++) {
> + mode_map->button_pairs[i].pair_index = i + 1;
> + ret = ally_set_button_mapping(hdev,
> + &mode_map->button_pairs[i]);
> + if (ret < 0) {
> + /*
> + * Pairs are pushed one at a time. This pair
> + * already reached the hardware when a later
> + * pair is the one that failed.
> + */
> + if (i > pair_idx - 1)
> + goto err_restore_hw;
> + goto err_restore;
> + }
> + }
> + }
> + sysfs_notify(&dev->kobj, ally_button_names[btn_attr->button_id],
> + btn_attr->is_macro ? "macro" : "remap");
> + return count;
> +
> +err_restore_hw:
> + *target_map = old_code;
> +
> + /* Try to recover the mapping presented to the user. */
> + ally_set_button_mapping(hdev, pair);
> + goto err_out;
> +
> +err_restore:
> + *target_map = old_code;
> +
> +err_out:
> + hid_err(hdev, "Failed to set button mapping: %d\n", ret);
> + return ret;
> +}
[Severity: Low]
This isn't a bug, but button_remap_store() mixes guard(mutex) with
goto-based error handling (err_restore_hw, err_restore, err_out).
Likewise, ally_create_button_attributes() below mixes __free(kfree) on
entries with goto ally_btn_err_cleanup. The cleanup.h convention is to
avoid mixing scope-based cleanup helpers and goto unwinding within the
same function.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106142334.1881-1-denis.benato@linux.dev?part=12
next prev parent reply other threads:[~2026-11-06 14:46 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
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 [this message]
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-201604@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