Skip to content

Commit 0403e10

Browse files
committed
hwmon: (nct6775-core) Fix underflows seen when writing limit attributes
DIV_ROUND_CLOSEST() after kstrtol() results in an underflow if a large negative number such as -9223372036854775808 is provided by the user. Fix it by reordering clamp_val() and DIV_ROUND_CLOSEST() operations. Signed-off-by: Guenter Roeck <[email protected]>
1 parent af64e3e commit 0403e10

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hwmon/nct6775-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ store_temp_offset(struct device *dev, struct device_attribute *attr,
22622262
if (err < 0)
22632263
return err;
22642264

2265-
val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -128, 127);
2265+
val = DIV_ROUND_CLOSEST(clamp_val(val, -128000, 127000), 1000);
22662266

22672267
mutex_lock(&data->update_lock);
22682268
data->temp_offset[nr] = val;

0 commit comments

Comments
 (0)