[PATCH] hwmon: (w83795) Clamp fan control times before rounding
From: Zhu Jun
Date: Wed Nov 11 2026 - 01:58:57 EST
time_to_reg() adds 50 before clamping the result. An unsigned long close
to ULONG_MAX wraps, so an excessive stop time can select zero rather
than the maximum. The same conversion is used for fan speed transition
times.
Clamp to the maximum representable duration before adding the rounding
adjustment.
Fixes: 792d376b4f3f ("hwmon: New driver for the W83795G/ADG monitoring chips")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
drivers/hwmon/w83795.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c
index 96fbb0a5006f..9b0ef0c8c5b7 100644
--- a/drivers/hwmon/w83795.c
+++ b/drivers/hwmon/w83795.c
@@ -260,7 +260,7 @@ static inline unsigned long time_from_reg(u8 reg)
static inline u8 time_to_reg(unsigned long val)
{
- return clamp_val((val + 50) / 100, 0, 0xff);
+ return (min(val, 25500UL) + 50) / 100;
}
static inline long temp_from_reg(s8 reg)
--
2.51.0