• Guenter Roeck's avatar
    hwmon: (max16065) Fix overflows seen when writing limits · 744ec447
    Guenter Roeck authored
    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: default avatarTzung-Bi Shih <tzungbi@kernel.org>
    Fixes: f5bae264 ("hwmon: Driver for MAX16065 System Manager and compatibles")
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    744ec447
max16065.c 18.8 KB