[PATCH 0/3] hwmon: fix jiffies wraparound in one-shot ready checks

From: Tom Verdonck

Date: Fri Sep 25 2026 - 14:23:42 EST


Several hwmon drivers store a one-shot jiffies deadline that is set once
and never refreshed, then compare it against the current time with
time_before() on every access. time_before() only interprets the signed
difference of two jiffies values correctly while they are within
LONG_MAX jiffies of each other. Because the deadline is frozen while
jiffies keeps advancing, the difference eventually flips sign: after
2^31 jiffies (~248.5 days of uptime on a 32-bit HZ=100 kernel) the check
inverts and stays wrong for the next ~248.5 days.

The consequences differ per driver:

- tmp102, tmp108: every temperature read then returns -EAGAIN without
ever touching the sensor, until the machine is rebooted. This has
been observed in the field on 32-bit systems that had been up for
~248 days.
- sht4x: the read path instead concludes the heater is still active
and calls msleep() with a bogus, huge delta, blocking the read for a
very long time.

Each is fixed the same minimal way: store the deadline in a u64 jiffies
value and compare it with get_jiffies_64()/time_before64(), which does
not wrap in any realistic uptime. No functional change on the hot path
other than removing the false-positive after the wrap point.

The other hwmon time_before(jiffies, ...) users I looked at are not
affected: they either re-stamp last_updated on every update (the usual
cache pattern, e.g. tmp421, tmp464, tc654, g762, ibmpex, w83792d) or use
a freshly computed local timeout (pmbus/ltc2978), so their two operands
never drift apart.

The failure itself takes ~248 days of uptime to reproduce and follows
directly from the time_before() semantics; it was traced from a field
report of a 32-bit board stuck returning -EAGAIN after ~248 days.

Build-tested on x86-64 and cross-compiled for 32-bit ARM (Cortex-A7,
arm-linux-gnueabi) with make W=1; all three objects build cleanly with
no new warnings. 32-bit ARM is the configuration in which the bug
actually manifests.

Tom Verdonck (3):
hwmon: (tmp102) Fix jiffies wraparound in conversion-ready check
hwmon: (tmp108) Fix jiffies wraparound in conversion-ready check
hwmon: (sht4x) Fix jiffies wraparound in heater-ready check

drivers/hwmon/sht4x.c | 18 +++++++++---------
drivers/hwmon/tmp102.c | 8 ++++----
drivers/hwmon/tmp108.c | 8 ++++----
3 files changed, 17 insertions(+), 17 deletions(-)

--
2.53.0