From: Guenter Roeck <linux@roeck-us.net>
To: Tom Verdonck <tom.verdonck@inspiral.be>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] hwmon: (sht4x) Fix torn read of heating_complete in heater_enable_show()
Date: Sun, 18 Oct 2026 09:23:35 -0700 [thread overview]
Message-ID: <26a02aca-2067-48f8-a26d-2edef878751f@roeck-us.net> (raw)
In-Reply-To: <20260928062238.67746-1-tom.verdonck@inspiral.be>
On Mon, Sep 28, 2026 at 08:22:38AM +0200, Tom Verdonck wrote:
> Commit 61406e9cac69 ("hwmon: (sht4x) Fix jiffies wraparound in
> heater-ready check") widened ->heating_complete from unsigned long to
> u64. On 32-bit architectures a u64 is no longer loaded and stored
> atomically, so heater_enable_show(), which reads ->heating_complete
> without any locking, can race heater_enable_store() and observe a torn
> value, reporting a wrong heater state.
>
> Take the hwmon lock in heater_enable_show(), as heater_enable_store()
> already does when it updates ->heating_complete. The other reader,
> sht4x_read_values(), is only reached through the hwmon read callback,
> which the hwmon core already serializes with the same lock.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/cover.1790358356.git.tom.verdonck@inspiral.be?part=3
> Fixes: 61406e9cac69 ("hwmon: (sht4x) Fix jiffies wraparound in heater-ready check")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tom Verdonck <tom.verdonck@inspiral.be>
> ---
> Guenter, if the hwmon branch has not gone to Linus yet, feel free to
> squash this into commit 61406e9cac69 ("hwmon: (sht4x) Fix jiffies
> wraparound in heater-ready check") instead.
I'll do that.
Thanks,
Guenter
>
> drivers/hwmon/sht4x.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hwmon/sht4x.c b/drivers/hwmon/sht4x.c
> index da2b6130fca7..27fddff70354 100644
> --- a/drivers/hwmon/sht4x.c
> +++ b/drivers/hwmon/sht4x.c
> @@ -237,6 +237,8 @@ static ssize_t heater_enable_show(struct device *dev,
> {
> struct sht4x_data *data = dev_get_drvdata(dev);
>
> + guard(hwmon_lock)(dev);
> +
> return sysfs_emit(buf, "%u\n", time_before64(get_jiffies_64(), data->heating_complete));
> }
>
prev parent reply other threads:[~2026-10-18 16:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 18:23 [PATCH 0/3] hwmon: fix jiffies wraparound in one-shot ready checks Tom Verdonck
2026-09-25 18:23 ` [PATCH 1/3] hwmon: (tmp102) Fix jiffies wraparound in conversion-ready check Tom Verdonck
2026-09-26 3:25 ` Guenter Roeck
2026-09-25 18:23 ` [PATCH 2/3] hwmon: (tmp108) " Tom Verdonck
2026-09-26 3:26 ` Guenter Roeck
2026-09-25 18:23 ` [PATCH 3/3] hwmon: (sht4x) Fix jiffies wraparound in heater-ready check Tom Verdonck
2026-09-26 3:27 ` Guenter Roeck
2026-09-28 6:22 ` [PATCH] hwmon: (sht4x) Fix torn read of heating_complete in heater_enable_show() Tom Verdonck
2026-10-18 16:23 ` Guenter Roeck [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=26a02aca-2067-48f8-a26d-2edef878751f@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tom.verdonck@inspiral.be \
/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
all inboxes | Powered by JetHome®