diff options
author | Guenter Roeck <linux@roeck-us.net> | 2024-07-06 23:50:08 -0700 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2024-07-07 07:48:25 -0700 |
commit | 0403e10bf0824bf0ec2bb135d4cf1c0cc3bf4bf0 (patch) | |
tree | 1fd955da298e2d75b8579d4c678d7d8066ce3c56 /drivers/hwmon/nct6775-core.c | |
parent | af64e3e1537896337405f880c1e9ac1f8c0c6198 (diff) | |
download | lwn-0403e10bf0824bf0ec2bb135d4cf1c0cc3bf4bf0.tar.gz lwn-0403e10bf0824bf0ec2bb135d4cf1c0cc3bf4bf0.zip |
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>
Diffstat (limited to 'drivers/hwmon/nct6775-core.c')
-rw-r--r-- | drivers/hwmon/nct6775-core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c index 9fbab8f02334..934fed3dd586 100644 --- a/drivers/hwmon/nct6775-core.c +++ b/drivers/hwmon/nct6775-core.c @@ -2262,7 +2262,7 @@ store_temp_offset(struct device *dev, struct device_attribute *attr, if (err < 0) return err; - val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -128, 127); + val = DIV_ROUND_CLOSEST(clamp_val(val, -128000, 127000), 1000); mutex_lock(&data->update_lock); data->temp_offset[nr] = val; |