]> www.infradead.org Git - users/jedix/linux-maple.git/commit
hwmon: (max16065) Fix overflows seen when writing limits
authorGuenter Roeck <linux@roeck-us.net>
Thu, 18 Jul 2024 16:52:01 +0000 (09:52 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 31 Jul 2024 17:43:52 +0000 (10:43 -0700)
commit744ec4477b11c42e2c8de9eb8364675ae7a0bd81
tree5fc9ddf1626a0def4c9e28eea37832ecabaaa996
parent97adb1aacef8f3f3ec3363ac1f8b72db432f55f0
hwmon: (max16065) Fix overflows seen when writing limits

Writing large limits resulted in overflows as reported by module tests.

in0_lcrit: Suspected overflow: [max=5538, read 0, written 2147483647]
in0_crit: Suspected overflow: [max=5538, read 0, written 2147483647]
in0_min: Suspected overflow: [max=5538, read 0, written 2147483647]

Fix the problem by clamping prior to multiplications and the use of
DIV_ROUND_CLOSEST, and by using consistent variable types.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Fixes: f5bae2642e3d ("hwmon: Driver for MAX16065 System Manager and compatibles")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/max16065.c