diff options
| author | Guenter Roeck <linux@roeck-us.net> | 2024-07-06 23:50:08 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-09-12 11:11:36 +0200 |
| commit | 2f695544084a559f181cafdfd3f864c5ff9dd1db (patch) | |
| tree | 26e20ebc9d13a7446cf0aae8e37e59861df0c921 /drivers/hwmon | |
| parent | 46e4fd338d5bdbaf60e41cda625b24949d2af201 (diff) | |
| download | linux-2f695544084a559f181cafdfd3f864c5ff9dd1db.tar.gz linux-2f695544084a559f181cafdfd3f864c5ff9dd1db.tar.bz2 linux-2f695544084a559f181cafdfd3f864c5ff9dd1db.zip | |
hwmon: (nct6775-core) Fix underflows seen when writing limit attributes
[ Upstream commit 0403e10bf0824bf0ec2bb135d4cf1c0cc3bf4bf0 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hwmon')
| -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 f3bf2e4701c3..8da7aa1614d7 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; |
