Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Derek J. Clark" <derekjohn.clark@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v4 4/4] HID: hid-msi: Add Rumble Intensity Attributes
Date: Sat, 16 May 2026 06:21:41 +0000	[thread overview]
Message-ID: <20260516062141.822D9C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260516042841.500299-5-derekjohn.clark@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] State machine desynchronization and data corruption due to lockless `profile_pending` and lack of request sequence verification.
- [Medium] Undocumented and broken modification to button mapping functionality.
- [Medium] Data race on `rumble_intensity_left` and `rumble_intensity_right` variables due to inconsistent locking.
--

commit e2268bfaf4019b28116f3a16f5112af6d91c10d6
Author: Derek J. Clark <derekjohn.clark@gmail.com>

HID: hid-msi: Add Rumble Intensity Attributes

This commit adds sysfs attributes to adjust the left and right rumble
intensity for MSI claw devices.

> Adds intensity adjustment for the left and right rumble motors.

The commit message states this patch only adds intensity adjustment for the
left and right rumble motors, but it introduces undocumented changes to the
button mapping functionality.

> diff --git a/drivers/hid/hid-msi.c b/drivers/hid/hid-msi.c
> --- a/drivers/hid/hid-msi.c
> +++ b/drivers/hid/hid-msi.c
> @@ -234,6 +236,7 @@ static const struct {
>  	{ 0xcc, "BTN_EXTRA" },
>  	{ 0xcd, "REL_WHEEL_UP" },
>  	{ 0xce, "REL_WHEEL_DOWN" },
> +	{ 0xff, "DISABLED" },
>  };

[ ... ]

> @@ -678,6 +695,9 @@ static const char *button_mapping_code_to_name(u8 code)
>  {
>  	int i;
>  
> +	if (code == 0xff)
> +		return NULL;
> +

Does this logic prevent the newly added "DISABLED" mapping from ever being
returned? By explicitly returning NULL here, will callers print "(null)" to
userspace instead of the intended "DISABLED" string?

[ ... ]

> @@ -400,6 +411,12 @@ static int claw_profile_event(struct claw_drvdata *drvdata, struct claw_command_
>  			drvdata->led_mc.subled_info[2].intensity = frame->zone_data.zone[0].blue;
>  		}
>  
> +		break;
> +	case CLAW_RUMBLE_LEFT_PENDING:
> +		drvdata->rumble_intensity_left = cmd_rep->data[4];
> +		break;
> +	case CLAW_RUMBLE_RIGHT_PENDING:
> +		drvdata->rumble_intensity_right = cmd_rep->data[4];
>  		break;

Are these assignments exposed to a data race?

This function updates the rumble intensity variables asynchronously without
holding any locks. However, the variables are read and written elsewhere
using entirely different locks:

rumble_intensity_left_store():
    guard(mutex)(&drvdata->rom_mutex);
    ...
    drvdata->rumble_intensity_left = val;

rumble_intensity_left_show():
    guard(mutex)(&drvdata->profile_mutex);
    ...
    return sysfs_emit(buf, "%u\n", drvdata->rumble_intensity_left);

Additionally, is there a risk of cross-talk if a delayed hardware ACK arrives
after a timeout?

If rumble_intensity_left_show() times out while waiting for
claw_hw_output_report(), it resets profile_pending to CLAW_NO_PENDING and
drops profile_mutex. The hardware command is not aborted.

If rumble_intensity_right_show() is subsequently called, it sets
profile_pending to CLAW_RUMBLE_RIGHT_PENDING.

If the delayed left motor ACK arrives at this exact moment, it appears
claw_profile_event() will observe CLAW_RUMBLE_RIGHT_PENDING.

Since this function does not verify the response address for rumble
requests, could it incorrectly assign the incoming left motor data to
drvdata->rumble_intensity_right?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260516042841.500299-1-derekjohn.clark@gmail.com?part=4

      reply	other threads:[~2026-05-16  6:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-16  4:28 [PATCH v4 0/4] Add MSI Claw HID Configuration Driver Derek J. Clark
2026-05-16  4:28 ` [PATCH v4 1/4] HID: hid-msi: Add MSI Claw configuration driver Derek J. Clark
2026-05-16  5:01   ` sashiko-bot
2026-05-16  4:28 ` [PATCH v4 2/4] HID: hid-msi: Add M-key mapping attributes Derek J. Clark
2026-05-16  5:27   ` sashiko-bot
2026-05-16  4:28 ` [PATCH v4 3/4] HID: hid-msi: Add RGB control interface Derek J. Clark
2026-05-16  5:48   ` sashiko-bot
2026-05-16  4:28 ` [PATCH v4 4/4] HID: hid-msi: Add Rumble Intensity Attributes Derek J. Clark
2026-05-16  6:21   ` 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=20260516062141.822D9C19425@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