Skip to contentSkip to conversation

hwmon: (aht10) Fix update_interval overflow on 64-bit

PATCH Applied Rupesh Majhi 3 participants 3 messages Nov 8 – Nov 9 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (aht10) Fix update_interval overflow on 64-bit

On 64-bit, update_interval writes are clamped to LONG_MAX ms, but ms_to_ktime() overflows above 9223372036854 ms and the interval wraps. LONG_MAX becomes -1 ms, so every read starts a new measurement and update_interval reads back -1.

Clamp to INT_MAX like sht4x, so the limit is the same on all platforms.

Fixes 8c78f0dee437 ("hwmon: Add AHT10 Temperature and Humidity Sensor Driver")

---
Tested on x86_64 in QEMU with an emulated AHT20.

 drivers/hwmon/aht10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/aht10.c +1 -1
index 6c263cb57766..c9ee50883f5d 100644
@@ -222,7 +222,7 @@ static int aht10_read_values(struct aht10_data *data)
 static ssize_t aht10_interval_write(struct aht10_data *data,
 				    long val)
 {
-	data->min_poll_interval = ms_to_ktime(clamp_val(val, 2000, LONG_MAX));
+	data->min_poll_interval = ms_to_ktime(clamp_val(val, 2000, INT_MAX));
 	return 0;
 }
 

base-commit: f4e680ffc2e50867c5b590e26a37f8801a31e486

Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

On 64-bit, update_interval writes are clamped to LONG_MAX ms, but ms_to_ktime() overflows above 9223372036854 ms and the interval wraps. LONG_MAX becomes -1 ms, so every read starts a new measurement and update_interval reads back -1.

Clamp to INT_MAX like sht4x, so the limit is the same on all platforms.

Fixes 8c78f0dee437 ("hwmon: Add AHT10 Temperature and Humidity Sensor Driver")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Applied
#2 lore raw
In reply to Rupesh Majhi
Quoted 9 lines · Rupesh Majhi

On 64-bit, update_interval writes are clamped to LONG_MAX ms, but ms_to_ktime() overflows above 9223372036854 ms and the interval wraps. LONG_MAX becomes -1 ms, so every read starts a new measurement and update_interval reads back -1.

Clamp to INT_MAX like sht4x, so the limit is the same on all platforms.

Fixes 8c78f0dee437 ("hwmon: Add AHT10 Temperature and Humidity Sensor Driver")

Applied.

Thanks,
Guenter