Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eugene Shalygin" <eugene.shalygin@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (asus-ec-sensors) fix EC read intervals
Date: Sun, 12 Jul 2026 11:02:05 +0000	[thread overview]
Message-ID: <20260712110205.A3CC61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260712105422.920360-1-eugene.shalygin@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditional advancement of the update timestamp masks hardware read errors, causing silent propagation of stale or uninitialized data to userspace.
--

--- Patch [1]: [PATCH] hwmon: (asus-ec-sensors) fix EC read intervals ---
commit 6080114048f396c35a55a9a09a1833289acbf3be
Author: Eugene Shalygin <eugene.shalygin@gmail.com>

hwmon: (asus-ec-sensors) fix EC read intervals

This commit updates the driver to take INITIAL_JIFFIES into account when
setting up the next update time. It changes the last_updated tracker to a
next_update timestamp and advances it by HZ prior to performing hardware
sensor reads.

> diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
> index 29a23484cbe7b..4746c3718664b 100644
> --- a/drivers/hwmon/asus-ec-sensors.c
> +++ b/drivers/hwmon/asus-ec-sensors.c

[ ... ]

> @@ -1278,13 +1278,12 @@ static int get_cached_value_or_update(const struct device *dev,
>  				      int sensor_index,
>  				      struct ec_sensors_data *state, s32 *value)
>  {
> -	if (time_after(jiffies, state->last_updated + HZ)) {
> +	if (time_after64(get_jiffies_64(), state->next_update)) {
> +		state->next_update = get_jiffies_64() + HZ;
>  		if (update_ec_sensors(dev, state)) {

[Severity: High]
Does unconditional advancement of state->next_update before verifying the
hardware read succeeded cause stale data to be reported to userspace?

If update_ec_sensors() fails (for example, due to ACPI mutex contention
returning -EBUSY), the timestamp remains advanced. Any subsequent attribute
reads within the 1-second timeout window will bypass the update check.

These subsequent reads will successfully return uninitialized (zero) or stale
cached_value data with a return code of 0, potentially disrupting thermal
management policies.

>  			dev_err(dev, "update_ec_sensors() failure\n");
>  			return -EIO;
>  		}
> -
> -		state->last_updated = jiffies;
>  	}
>  
>  	*value = state->sensors[sensor_index].cached_value;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260712105422.920360-1-eugene.shalygin@gmail.com?part=1

      reply	other threads:[~2026-07-12 11:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 10:54 [PATCH] hwmon: (asus-ec-sensors) fix EC read intervals Eugene Shalygin
2026-07-12 11:02 ` 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=20260712110205.A3CC61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eugene.shalygin@gmail.com \
    --cc=linux-hwmon@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