power: supply: twl4030_charger: fix charging current out-of-bounds
authorAndreas Kemnade <andreas@kemnade.info>
Mon, 17 Sep 2018 05:20:35 +0000 (07:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:47:01 +0000 (18:47 +0100)
commit773fb69e430751062015467e9f97f35158bd3bf9
treee197b480b0dab096b347a6b1303063b4728a4d0a
parent0729f87b840a12daab0a1dc95e8939abbf89ec57
power: supply: twl4030_charger: fix charging current out-of-bounds

[ Upstream commit 8314c212f995bc0d06b54ad02ef0ab4089781540 ]

the charging current uses unsigned int variables, if we step back
if the current is still low, we would run into negative which
means setting the target to a huge value.
Better add checks here.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/power/supply/twl4030_charger.c