mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
supply: rk817: Fix battery capacity sanity check calculation
If the nvram variable is corrupted in a way that multiplying it by 1000 causes an integer overflow and wraps around to a number within or below the sanity check bounds, the check fails and capacity is reported incorrectly. Change the sanity check calculation to not multiply the variable read from the rk817 nvram, preventing the overflow and resulting in all corrupt capacity values being detected. Signed-off-by: Alexander Warnecke <awarnecke002@hotmail.com>
This commit is contained in:
committed by
Mauro (mdrjr) Ribeiro
parent
8a380517b4
commit
9072f9d428
@@ -715,7 +715,7 @@ static int rk817_read_battery_nvram_values(struct rk817_charger *charger)
|
||||
* correct it.
|
||||
*/
|
||||
if ((charger->fcc_mah < 500) ||
|
||||
((charger->fcc_mah * 1000) > charger->bat_charge_full_design_uah)) {
|
||||
(charger->fcc_mah > (charger->bat_charge_full_design_uah / 1000))) {
|
||||
dev_info(charger->dev,
|
||||
"Invalid NVRAM max charge, setting to %u uAH\n",
|
||||
charger->bat_charge_full_design_uah);
|
||||
|
||||
Reference in New Issue
Block a user