]> www.infradead.org Git - users/jedix/linux-maple.git/commit
hwmon: (ina2xx) Fix various overflow issues
authorGuenter Roeck <linux@roeck-us.net>
Wed, 24 Jul 2024 16:42:16 +0000 (09:42 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 30 Aug 2024 15:34:23 +0000 (08:34 -0700)
commitab7fbee452beca56b7c570d49190e679863362d5
tree2655feac450eab071f410464a3e1c913229908a6
parentbb25cdc2bff408ee3be1f20bd2cee4ea8b79c2d6
hwmon: (ina2xx) Fix various overflow issues

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: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina2xx.c