Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <linux@roeck-us.net>

+1 -1
+1 -1
drivers/hwmon/nct6775-core.c
··· 2262 2262 if (err < 0) 2263 2263 return err; 2264 2264 2265 - val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -128, 127); 2265 + val = DIV_ROUND_CLOSEST(clamp_val(val, -128000, 127000), 1000); 2266 2266 2267 2267 mutex_lock(&data->update_lock); 2268 2268 data->temp_offset[nr] = val;