]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Dec 2021 11:28:47 +0000 (12:28 +0100)
commitd105f30bea9104c590a9e5b495cb8a49bdfe405f
treecfeebb302e89dcc2142ed817058685ca27d09686
parent4b8f0e940972ac34128efbe6cfb904356d088bfe
hwmon: (lm90) Prevent integer overflow/underflow in hysteresis calculations

[ Upstream commit 55840b9eae5367b5d5b29619dc2fb7e4596dba46 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/lm90.c