• Guenter Roeck's avatar
    hwmon: (ina2xx) Fix various overflow issues · ab7fbee4
    Guenter Roeck authored
    Module tests show various overflow problems when writing limits
    and other attributes.
    
    in0_crit: Suspected overflow: [max=82, read 0, written 2147483648]
    in0_lcrit: Suspected overflow: [max=82, read 0, written 2147483648]
    in1_crit: Suspected overflow: [max=40959, read 0, written 2147483647]
    in1_lcrit: Suspected overflow: [max=40959, read 0, written 2147483647]
    power1_crit: Suspected overflow: [max=134218750, read 0, written 2147483648]
    update_interval: Suspected overflow: [max=2253, read 2, written 2147483647]
    
    Implement missing clamping on attribute write operations to avoid those
    problems.
    
    While at it, check in the probe function if the shunt resistor value
    passed from devicetree is valid, and bail out if it isn't. Also limit
    mutex use to the code calling ina2xx_set_shunt() since it isn't needed
    when called from the probe function.
    Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    ab7fbee4
ina2xx.c 20.1 KB