linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Andreas Kemnade <andreas@kemnade.info>
Cc: sre@kernel.org, linux-pm@vger.kernel.org,
	linux-omap@vger.kernel.org,
	Discussions about the Letux Kernel <letux-kernel@openphoenux.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] twl4030_charger: fix charging current out-of-bounds
Date: Sun, 30 Sep 2018 22:16:42 +0200	[thread overview]
Message-ID: <20180930201642.GC23554@amd> (raw)
In-Reply-To: <20180917052035.12234-1-andreas@kemnade.info>

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

On Mon 2018-09-17 07:20:35, Andreas Kemnade wrote:
> 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.

Do you expect this to happen in practice? Too high current while
charging seems bad, right?

Cc: stable?
								Pavel

> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
>  drivers/power/supply/twl4030_charger.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
> index b72838663872..c954b7234393 100644
> --- a/drivers/power/supply/twl4030_charger.c
> +++ b/drivers/power/supply/twl4030_charger.c
> @@ -421,7 +421,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) {

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  parent reply	other threads:[~2018-09-30 20:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-17  5:20 [PATCH RESEND] twl4030_charger: fix charging current out-of-bounds Andreas Kemnade
2018-09-20  0:20 ` Sebastian Reichel
2018-09-30 20:16 ` Pavel Machek [this message]
2018-10-01  5:55   ` Andreas Kemnade

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180930201642.GC23554@amd \
    --to=pavel@ucw.cz \
    --cc=andreas@kemnade.info \
    --cc=letux-kernel@openphoenux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).