Commit 8314c212 authored by Andreas Kemnade's avatar Andreas Kemnade Committed by Sebastian Reichel
Browse files

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: default avatarAndreas Kemnade <andreas@kemnade.info>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent ad1570d9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -420,6 +420,7 @@ static void twl4030_current_worker(struct work_struct *data)

	if (v < USB_MIN_VOLT) {
		/* Back up and stop adjusting. */
		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 ||