From: sashiko-bot@kernel.org
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 2/3] hwmon: (cros_ec) Store the hwmon device in cros_ec_hwmon_priv
Date: Sat, 11 Jul 2026 10:05:17 +0000 [thread overview]
Message-ID: <20260711100517.A99871F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260711-cros_ec-hwmon-locking-v1-2-cb6d0fdbb2d3@weissschuh.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] A TOCTOU race condition exists between thermal core cooling state updates and hwmon sysfs attribute writes, leading to the EC fan control mode being unintentionally overridden from auto back to manual.
--
--- Patch [2]: [PATCH 2/3] hwmon: (cros_ec) Store the hwmon device in cros_ec_hwmon_priv ---
commit 7ca9614b2a60a2ddf82816080be1dcfa8ab66da6
Author: Thomas Weißschuh <linux@weissschuh.net>
hwmon: (cros_ec) Store the hwmon device in cros_ec_hwmon_priv
This patch adds a pointer to the hwmon device within the cros_ec_hwmon_priv
structure. The change prepares the driver for an upcoming locking scheme
for thermal devices that requires access to the hwmon device.
> diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
> index f9b19da50472d..fb5daa9f80d1c 100644
> --- a/drivers/hwmon/cros_ec_hwmon.c
> +++ b/drivers/hwmon/cros_ec_hwmon.c
> @@ -25,6 +25,7 @@
>
> struct cros_ec_hwmon_priv {
> struct cros_ec_device *cros_ec;
> + struct device *hwmon_dev;
[Severity: High]
This is a pre-existing issue, but since this patch prepares the driver for
an upcoming thermal locking scheme, is there a TOCTOU race condition during
PWM updates without hwmon_lock() serialization?
Looking at cros_ec_hwmon_write_pwm_input(), which can be called by the thermal
core to update the cooling state:
static int cros_ec_hwmon_write_pwm_input(struct cros_ec_device *cros_ec, u8 index, u8 val)
{
u8 control_method;
int ret;
ret = cros_ec_hwmon_read_pwm_enable(cros_ec, index, &control_method);
if (ret)
return ret;
if (control_method != 1)
return -EOPNOTSUPP;
return cros_ec_hwmon_set_fan_pwm_val(cros_ec, index, val);
}
If a concurrent user-space thread writes to the hwmon_pwm_enable sysfs
attribute to set the mode to auto after the control_method check, the EC
successfully transitions to auto.
When the thermal core thread resumes and writes the PWM value via
cros_ec_hwmon_set_fan_pwm_val(), the EC implicitly reverts the fan control
mode back to manual.
If the mode is overridden back to manual after user-space successfully set it
to auto, the fan could remain stuck at a low or zero PWM speed. Does this
path need to be protected by hwmon_lock() to ensure the fan control mode
is not unintentionally altered?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260711-cros_ec-hwmon-locking-v1-0-cb6d0fdbb2d3@weissschuh.net?part=2
next prev parent reply other threads:[~2026-07-11 10:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 9:59 [PATCH 0/3] hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks Thomas Weißschuh
2026-07-11 9:59 ` [PATCH 1/3] hwmon: (cros_ec) Register the thermal devices after the hwmon ones Thomas Weißschuh
2026-07-11 10:10 ` sashiko-bot
2026-07-11 9:59 ` [PATCH 2/3] hwmon: (cros_ec) Store the hwmon device in cros_ec_hwmon_priv Thomas Weißschuh
2026-07-11 10:05 ` sashiko-bot [this message]
2026-07-11 9:59 ` [PATCH 3/3] hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks Thomas Weißschuh
2026-07-11 10:04 ` sashiko-bot
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=20260711100517.A99871F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@weissschuh.net \
--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