All of lore.kernel.org
 help / color / mirror / Atom feed
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 v11 02/18] HID: asus: add gamepad configuration
Date: Mon, 26 Oct 2026 00:10:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-184555@kernel.org> (raw)
In-Reply-To: <20261025235232.129945-3-denis.benato@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] HID: asus: premature cfg_hdev role release in hid_asus_ally_remove()
--

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

HID: asus: add gamepad configuration

This commit adds the base configuration structures and sysfs attribute
groups for ROG Ally gamepad configuration, detects hardware capabilities,
and initializes the controller into a known state.

> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 9e6796bbbdcbd..6d1007433daa8 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c

[ ... ]

> @@ -1162,8 +1531,25 @@ static void hid_asus_ally_remove(struct hid_device *hdev, struct ally_handheld *
>  		ally->keyboard_input = NULL;
>  		ally->keyboard_hdev = NULL;
>  	}
> +
> +	owns_cfg = ally->cfg_hdev == hdev;
> +	if (owns_cfg) {
> +		cfg = ally->config;
> +		ally->cfg_hdev = NULL;
> +		ally->config = NULL;
> +	}
> +
>  	spin_unlock_irqrestore(&ally_data_lock, flags);
>  
> +	/*
> +	 * The config teardown removes sysfs groups and takes sleeping locks:
> +	 * it must not run under ally_data_lock. The config pointer has been
> +	 * unpublished above, so no new sysfs callback can find it while the
> +	 * groups are being removed.
> +	 */
> +	if (owns_cfg)
> +		ally_config_remove(hdev, cfg);

[Severity: Medium]
In hid_asus_ally_remove(), should ally->cfg_hdev be cleared only after
ally_config_remove(hdev, cfg) completes, rather than before it?

Clearing ally->cfg_hdev before ally_config_remove() releases the
HID_ALLY_INTF_CFG_IN role while sysfs_remove_group() is still sleeping (for
example, waiting in kernfs_drain() for an in-flight xbox_controller_store()
callback). During that window:

1. A concurrent hid_asus_ally_remove() on the last sibling interface sees
   ally_drvdata.cfg_hdev == NULL and ally_drvdata.cfg_probe_in_progress ==
   false in ally_put_udev_if_orphaned(), dropping ally_drvdata.udev early.

2. A concurrent hid_asus_ally_probe() for HID_ALLY_INTF_CFG_IN (from a
   re-enumerated device or duplicate endpoint) is no longer blocked by the
   role check:

	if ((ep == HID_ALLY_INTF_CFG_IN &&
	     (ally_drvdata.cfg_hdev || ally_drvdata.cfg_probe_in_progress)) ||

   and can enter ally_config_create() concurrently with ally_config_remove().

That allows ally_config_create() to mutate the singleton ally_config
(including cfg->initialized and the capability flags) and re-publish
ally->config = cfg while the old hdev's sysfs groups are still draining,
which also lets sysfs callbacks on the unbinding hdev see a non-NULL
ally_get_config() again.

By comparison, the hid_asus_ally_init() error path in hid_asus_ally_probe()
clears ally_drvdata.config = NULL under ally_data_lock, calls
ally_config_remove(), and only afterwards releases the role via
ally_probe_release_role(ep) and ally_put_udev_if_orphaned().

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

  reply	other threads:[~2026-10-26  0:10 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 23:52 [PATCH v11 00/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-10-25 23:52 ` [PATCH v11 01/18] " Denis Benato
2026-10-26  0:10   ` sashiko-bot
2026-10-26 12:38   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 02/18] HID: asus: add gamepad configuration Denis Benato
2026-10-26  0:10   ` sashiko-bot [this message]
2026-10-26 12:56   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 03/18] HID: asus: add vibration strength configuration Denis Benato
2026-10-25 23:52 ` [PATCH v11 04/18] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-10-26 13:00   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 05/18] HID: asus: add triggers " Denis Benato
2026-10-25 23:52 ` [PATCH v11 06/18] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-10-25 23:52 ` [PATCH v11 07/18] HID: asus: add support for response curve Denis Benato
2026-10-26 13:06   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 08/18] HID: asus: add support to force feedback Denis Benato
2026-10-26  0:19   ` sashiko-bot
2026-10-26 12:36   ` Sakari Ailus
2026-10-26 18:21     ` Ilpo Järvinen
2026-10-26 18:27       ` Sakari Ailus
2026-10-26 13:13   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 09/18] HID: asus: add support for gamepad mode Denis Benato
2026-10-26 13:20   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 10/18] HID: asus: add support for turbo buttons Denis Benato
2026-10-26 13:29   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 11/18] HID: asus: add support for btn remapping Denis Benato
2026-10-26  0:06   ` sashiko-bot
2026-10-26 14:03   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 12/18] HID: asus: size feature reports from the HID report descriptor Denis Benato
2026-10-26  0:06   ` sashiko-bot
2026-10-26 13:06   ` Rebecca Mara Müller
2026-10-26 19:38     ` Denis Benato
2026-10-25 23:52 ` [PATCH v11 13/18] HID: asus: identify XG Mobile stations and bind the LED to the reported model Denis Benato
2026-10-25 23:52 ` [PATCH v11 14/18] HID: asus: expose XG Mobile identity and firmware information Denis Benato
2026-10-26  0:05   ` sashiko-bot
2026-10-26 14:10   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 15/18] HID: asus: size ally gamepad commands from the HID report descriptor Denis Benato
2026-10-26  0:10   ` sashiko-bot
2026-10-25 23:52 ` [PATCH v11 16/18] platform/x86: asus-armoury: pick the eGPU activation from the reported GPU Denis Benato
2026-10-25 23:52 ` [PATCH v11 17/18] HID: asus: report the XG Mobile GPU vendor to asus-wmi Denis Benato
2026-10-26  0:03   ` sashiko-bot
2026-10-26 14:15   ` Ilpo Järvinen
2026-10-25 23:52 ` [PATCH v11 18/18] MAINTAINERS: add maintainer for the ASUS HID driver Denis Benato
2026-10-26 14:24 ` [PATCH v11 00/18] HID: asus: add support for ROG Ally handhelds Ilpo Järvinen
2026-10-26 18:03   ` 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-184555@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.