mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-21 03:33:59 +08:00
power: supply: twl4030_charger: fix charging current out-of-bounds
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>
This commit is contained in:
parent
ad1570d99f
commit
8314c212f9
@ -420,7 +420,8 @@ static void twl4030_current_worker(struct work_struct *data)
|
||||
|
||||
if (v < USB_MIN_VOLT) {
|
||||
/* Back up and stop adjusting. */
|
||||
bci->usb_cur -= USB_CUR_STEP;
|
||||
if (bci->usb_cur >= USB_CUR_STEP)
|
||||
bci->usb_cur -= USB_CUR_STEP;
|
||||
bci->usb_cur_target = bci->usb_cur;
|
||||
} else if (bci->usb_cur >= bci->usb_cur_target ||
|
||||
bci->usb_cur + USB_CUR_STEP > USB_MAX_CURRENT) {
|
||||
|
Loading…
Reference in New Issue
Block a user