[PATCH] hwmon: (w83793) Clamp fan control times before rounding
From: Zhu Jun
Date: Wed Nov 11 2026 - 01:55:45 EST
TIME_TO_REG() adds 50 to an unsigned long before applying its upper
bound. Writing ULONG_MAX to pwm1_stop_time therefore wraps and selects
zero instead of the maximum duration.
Clamp the duration to 25500 ms before rounding to the 100 ms register
units.
Fixes: 6800c3d027b4 ("hwmon: New Winbond W83793 hardware monitoring driver")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
drivers/hwmon/w83793.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index b1d390904fe4..b5d47c00c445 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -189,7 +189,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