[PATCH] hwmon: (w83627hf) Clamp VRM9 voltage limits before subtracting
From: Zhu Jun
Date: Wed Nov 11 2026 - 01:55:31 EST
The VRM9 limit conversion subtracts the 700 mV offset from an unsigned
value before clamping. Writing zero to in0_min or in0_max therefore
selects register 255 instead of zero. Multiplication can also wrap for
large inputs.
Bound the input before applying the VRM9 conversion. The chosen bounds
cover the full register range and keep the arithmetic within range.
Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
drivers/hwmon/w83627hf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index a26f4cdfb8e2..3ebb41db5033 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -853,7 +853,7 @@ static ssize_t in0_min_store(struct device *dev,
/* use VRM9 calculation */
data->in_min[0] =
- clamp_val(((val * 100) - 70000 + 244) / 488, 0, 255);
+ clamp_val((clamp_val(val, 700, 2000) * 100 - 70000 + 244) / 488, 0, 255);
else
/* use VRM8 (standard) calculation */
data->in_min[0] = IN_TO_REG(val);
@@ -892,7 +892,7 @@ static ssize_t in0_max_store(struct device *dev,
/* use VRM9 calculation */
data->in_max[0] =
- clamp_val(((val * 100) - 70000 + 244) / 488, 0, 255);
+ clamp_val((clamp_val(val, 700, 2000) * 100 - 70000 + 244) / 488, 0, 255);
else
/* use VRM8 (standard) calculation */
data->in_max[0] = IN_TO_REG(val);
--
2.51.0