]> git.ipfire.org Git - people/ms/linux.git/commit - drivers/hwmon/lm90.c
hwmon: (lm90) Prevent integer overflow/underflow in hysteresis calculations
authorGuenter Roeck <linux@roeck-us.net>
Wed, 17 Nov 2021 17:51:47 +0000 (09:51 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 13 Dec 2021 00:22:53 +0000 (16:22 -0800)
commit55840b9eae5367b5d5b29619dc2fb7e4596dba46
tree61bb69db6a6d8c3de293f49eb0c5380727f268c7
parentfce15c45d3fbd9fc1feaaf3210d8e3f8b33dfd3a
hwmon: (lm90) Prevent integer overflow/underflow in hysteresis calculations

Commit b50aa49638c7 ("hwmon: (lm90) Prevent integer underflows of
temperature calculations") addressed a number of underflow situations
when writing temperature limits. However, it missed one situation, seen
when an attempt is made to set the hysteresis value to MAX_LONG and the
critical temperature limit is negative.

Use clamp_val() when setting the hysteresis temperature to ensure that
the provided value can never overflow or underflow.

Fixes: b50aa49638c7 ("hwmon: (lm90) Prevent integer underflows of temperature calculations")
Cc: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/lm90.c