From: sashiko-bot@kernel.org
To: "Derek J. Clark" <derekjohn.clark@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v6 4/4] HID: hid-msi: Add Rumble Intensity Attributes
Date: Tue, 19 May 2026 00:22:01 +0000 [thread overview]
Message-ID: <20260519002201.EDBC5C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260518222935.1802071-5-derekjohn.clark@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] State machine desynchronization and data race on `profile_pending` leads to corrupted rumble intensity reads.
--
commit 85612b755f6822082f71e029c33a01200dc4046f
Author: Derek J. Clark <derekjohn.clark@gmail.com>
HID: hid-msi: Add Rumble Intensity Attributes
Adds intensity adjustment for the left and right rumble motors.
> diff --git a/drivers/hid/hid-msi.c b/drivers/hid/hid-msi.c
> index 4d267b896da72..339f256b60dbe 100644
> --- a/drivers/hid/hid-msi.c
> +++ b/drivers/hid/hid-msi.c
[ ... ]
> @@ -882,6 +901,142 @@ static ssize_t button_mapping_options_show(struct device *dev,
> }
> static DEVICE_ATTR_RO(button_mapping_options);
[ ... ]
> +static ssize_t rumble_intensity_left_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + u8 data[4] = { 0x01, (rumble_addr[0] >> 8) & 0xff, rumble_addr[0] & 0xff, 0x01 };
> + struct hid_device *hdev = to_hid_device(dev);
> + struct claw_drvdata *drvdata = hid_get_drvdata(hdev);
> + int ret;
> + u8 val;
> +
> + if (!drvdata->gamepad_registered)
> + return -ENODEV;
> +
> + guard(mutex)(&drvdata->profile_mutex);
> + drvdata->profile_pending = CLAW_RUMBLE_LEFT_PENDING;
> + ret = claw_hw_output_report(hdev, CLAW_COMMAND_TYPE_READ_PROFILE, data,
> + ARRAY_SIZE(data), 25);
> + if (ret) {
> + drvdata->profile_pending = CLAW_NO_PENDING;
> + return ret;
> + }
Can the profile_pending state become desynchronized if a hardware read times
out?
If claw_hw_output_report() times out, it sets
drvdata->profile_pending = CLAW_NO_PENDING and returns.
If a subsequent call to rumble_intensity_right_show() sets
drvdata->profile_pending = CLAW_RUMBLE_RIGHT_PENDING, and then the delayed
hardware ACK from the first left request arrives, claw_profile_event() will
misattribute the response.
It will read the left motor's intensity into drvdata->rumble_intensity_right,
corrupting the state:
case CLAW_RUMBLE_RIGHT_PENDING:
scoped_guard(spinlock_irqsave, &drvdata->rumble_lock)
drvdata->rumble_intensity_right = cmd_rep->data[4];
Additionally, claw_profile_event() clears
drvdata->profile_pending = CLAW_NO_PENDING locklessly at the end, which
could race with other process contexts accessing it under profile_mutex.
Should claw_profile_event() validate the memory address in the response payload
to ensure it belongs to the pending request, and synchronize accesses to
profile_pending?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518222935.1802071-1-derekjohn.clark@gmail.com?part=4
prev parent reply other threads:[~2026-05-19 0:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 22:29 [PATCH v6 0/4] Add MSI Claw HID Configuration Driver Derek J. Clark
2026-05-18 22:29 ` [PATCH v6 1/4] HID: hid-msi: Add MSI Claw configuration driver Derek J. Clark
2026-05-18 22:57 ` sashiko-bot
2026-05-18 22:29 ` [PATCH v6 2/4] HID: hid-msi: Add M-key mapping attributes Derek J. Clark
2026-05-18 23:29 ` sashiko-bot
2026-05-18 22:29 ` [PATCH v6 3/4] HID: hid-msi: Add RGB control interface Derek J. Clark
2026-05-18 23:56 ` sashiko-bot
2026-05-18 22:29 ` [PATCH v6 4/4] HID: hid-msi: Add Rumble Intensity Attributes Derek J. Clark
2026-05-19 0:22 ` sashiko-bot [this message]
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=20260519002201.EDBC5C2BCB7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=derekjohn.clark@gmail.com \
--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