]> git.baikalelectronics.ru Git - kernel.git/commit
power: supply: ip5xxx: Fix integer overflow in current_now calculation
authorOndrej Jirman <megi@xff.cz>
Fri, 28 Oct 2022 22:40:52 +0000 (00:40 +0200)
committerSebastian Reichel <sre@kernel.org>
Mon, 31 Oct 2022 23:02:36 +0000 (00:02 +0100)
commit319c82743272dee1980b364d44a8f883548df8c1
tree29deaa1db07ea6a611273463b9040f979b5da204
parent6ce69031a060b36c446d97432626b64fa7794c20
power: supply: ip5xxx: Fix integer overflow in current_now calculation

When current is larger than ~2A, the multiplication in current_now
property overflows and the kernel reports invalid negative current
value. Change the numerator and denominator while preserving their
ratio to allow up to +-6A before the overflow.

Fixes: e938b98db87d ("power: supply: Add a driver for Injoinic power bank ICs")
Signed-off-by: Ondrej Jirman <megi@xff.cz>
Reviewed-by: Samuel Holland <samuel@sholland.org>
[use 149197/200 instead of 261095/350 as suggested by Samuel]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/ip5xxx_power.c