From: sashiko-bot@kernel.org
To: "Matías Martínez" <hello@matias.me>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v3] HID: ayaneo: Add AYANEO 3 detachable controller driver
Date: Thu, 17 Sep 2026 16:16:16 +0000 [thread overview]
Message-ID: <20260917161617.7B3A31F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260917160722.89391-1-hello@matias.me>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hid: ayaneo: data race on completion state in ayaneo_cmd()
--
commit c219d53cacc831077bc77b38a3e4bceead638885
Author: Matías Martínez <hello@matias.me>
HID: ayaneo: Add AYANEO 3 detachable controller driver
This commit adds a HID driver for the AYANEO 3 detachable controller's
vendor interface. It provides support for module identification, software
eject, and RGB control of the joystick rings via the multicolor LED class.
The driver communicates with the device using a custom 65-byte command
protocol.
> diff --git a/drivers/hid/hid-ayaneo.c b/drivers/hid/hid-ayaneo.c
> new file mode 100644
> index 0000000000000..3a7af5918ee1e
> --- /dev/null
> +++ b/drivers/hid/hid-ayaneo.c
[ ... ]
> +static int ayaneo_cmd(struct ayaneo *aya, struct aya3_resp *resp)
> +{
> + int attempt, ret;
> +
> + lockdep_assert_held(&aya->lock);
> +
> + for (attempt = 0; attempt < AYA3_CMD_ATTEMPTS; attempt++) {
> + reinit_completion(&aya->resp_done);
[Severity: Medium]
Could this trigger a data race if a late hardware response arrives right as
the loop restarts?
If wait_for_completion_timeout() times out, the code loops back and calls
reinit_completion() while aya->resp_pending is still true. If the hardware
sends a late reply at this exact moment, ayaneo_raw_event() can read
aya->resp_pending as true and call complete() concurrently.
Since reinit_completion() modifies the completion locklessly while complete()
modifies it under a lock, this could corrupt the completion state and lead
to lost or phantom wakeups. Should aya->resp_pending be cleared before
reinitializing the completion, or perhaps cleared at the end of the timeout
path?
> + aya->resp_expect = aya->xfer[4];
> + WRITE_ONCE(aya->resp_pending, true);
> +
> + ret = ayaneo_send(aya);
> + if (ret) {
> + WRITE_ONCE(aya->resp_pending, false);
> + return ret;
> + }
> +
> + if (wait_for_completion_timeout(&aya->resp_done,
> + msecs_to_jiffies(AYA3_CMD_TIMEOUT_MS))) {
> + if (resp)
> + memcpy(resp, &aya->resp, sizeof(*resp));
> + return 0;
> + }
> + }
> + WRITE_ONCE(aya->resp_pending, false);
> + return -ETIMEDOUT;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917160722.89391-1-hello@matias.me?part=1
next prev parent reply other threads:[~2026-09-17 16:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 21:50 [PATCH] HID: ayaneo: Add AYANEO 3 detachable controller driver Matías Martínez
2026-08-24 22:00 ` Antheas Kapenekakis
2026-08-24 22:25 ` Antheas Kapenekakis
2026-08-24 22:47 ` Matías Martínez
2026-08-24 23:23 ` Antheas Kapenekakis
2026-08-25 17:21 ` Matías Martínez
2026-08-24 22:01 ` sashiko-bot
2026-08-24 22:47 ` Matías Martínez
2026-08-24 22:31 ` [PATCH v2] " Matías Martínez
2026-08-24 22:41 ` sashiko-bot
2026-09-17 16:07 ` [PATCH v3] " Matías Martínez
2026-09-17 16:16 ` sashiko-bot [this message]
2026-09-17 21:48 ` Antheas Kapenekakis
2026-09-17 22:23 ` Matías Martínez
2026-09-17 22:54 ` Antheas Kapenekakis
2026-09-18 0:42 ` Derek J. Clark
2026-09-18 1:38 ` Denis Benato
2026-09-18 7:52 ` Antheas Kapenekakis
2026-09-18 13:44 ` Derek J. Clark
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=20260917161617.7B3A31F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=hello@matias.me \
--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.