Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1360759imm; Wed, 19 Sep 2018 17:23:03 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaPbMqFCUZNVd3ofkeM0lz3xyfJkXwwq64OUzuuO2xGTZzpCLQBGsRsp8JlmY1J79iLoP0f X-Received: by 2002:a63:2c8e:: with SMTP id s136-v6mr35285712pgs.390.1537402982971; Wed, 19 Sep 2018 17:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537402982; cv=none; d=google.com; s=arc-20160816; b=TJZ0Xzh/u42+I6xKlkdcspH4n2qe6A7lvFPXqG8c3y7l2wfKXFrqgk0UmqWvlWtZfl cFuY4Uqfi7Rp/NLn4Plm7MakzECaR70QghJNVwmWiGt+nP9NQOggrKhITrYRJJ7dnCLU h9CbZqqWv87sgv0osG+XmntFmZcxZxoEyOQ2r9znNNfAj+s91ZMpuoOg2+S7W7PKpQAd phj3P7cPj4YF0Y3NGxMTPZp8Fu8x7xcfBJfbKsr25+dnY/JiTex9ITXfPcMF6hpz4eUD Zab7vzbGEef8tDa2bg6Kwv8blk+JuYWggAiMdXQddtmp7b3/NtTqZ0OSiZQVcyGgHNXA R4Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=c6GhKQcdZrTUAAtzy2tFV6QrvMHaP9aw+8QBbFF6Gb8=; b=ZaA7L8Knw5C2GSUk6/2yW0DeRe4cLU9TtFIWCFtaUOLIvGojrzIlsMfqaHelZC6ngw Bhh0W2c663mxS2OwdPpxPZPxqEeByIjpLnyW+bQ6UDc4mDn04clHViXXZQvSli9sr3jO RlGqonT20pHd4Xh+LFxDUWL8s3ZA8sHM7Xp7oN3HEwh/B+ns5NXjTT3XsX7uHURBUKqp itADufMNyTmWaGl2Uh2WrzagTtNR+tQo9SmrEceAc3A+vMSAhhxX3VM8FBGAjfhjG8x1 ZbRlw3K1OwNwtB9BidVR15UMc4BFJJmJotvTR6zLBTetCuuSaXWnrFhjgC2W6Uoy/g0i z0uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g65-v6si25553983plb.297.2018.09.19.17.22.17; Wed, 19 Sep 2018 17:23:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387597AbeITGBW (ORCPT + 99 others); Thu, 20 Sep 2018 02:01:22 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:41622 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727865AbeITGBW (ORCPT ); Thu, 20 Sep 2018 02:01:22 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id C5CB126B9CE Received: by earth.universe (Postfix, from userid 1000) id 5EFAE3C0A85; Thu, 20 Sep 2018 02:20:52 +0200 (CEST) Date: Thu, 20 Sep 2018 02:20:52 +0200 From: Sebastian Reichel To: Andreas Kemnade Cc: linux-pm@vger.kernel.org, linux-omap@vger.kernel.org, Discussions about the Letux Kernel , linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] twl4030_charger: fix charging current out-of-bounds Message-ID: <20180920002052.xex3xdrvzkb7wf7k@earth.universe> References: <20180917052035.12234-1-andreas@kemnade.info> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="tavpoct2v7do34bb" Content-Disposition: inline In-Reply-To: <20180917052035.12234-1-andreas@kemnade.info> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --tavpoct2v7do34bb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Mon, Sep 17, 2018 at 07:20:35AM +0200, 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. >=20 > Signed-off-by: Andreas Kemnade > --- Thanks, queued. -- Sebastian > drivers/power/supply/twl4030_charger.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/suppl= y/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) > =20 > if (v < USB_MIN_VOLT) { > /* Back up and stop adjusting. */ > - bci->usb_cur -=3D USB_CUR_STEP; > + if (bci->usb_cur >=3D USB_CUR_STEP) > + bci->usb_cur -=3D USB_CUR_STEP; > bci->usb_cur_target =3D bci->usb_cur; > } else if (bci->usb_cur >=3D bci->usb_cur_target || > bci->usb_cur + USB_CUR_STEP > USB_MAX_CURRENT) { > --=20 > 2.11.0 >=20 --tavpoct2v7do34bb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlui5+QACgkQ2O7X88g7 +pqu/w/+PuOEdsIBjlmz1T5XE3MmdQj/ox9PMIqczw1TcK2QH4ccBJGs0EHWKGFX CdGiFkWx/bH+cNkEAO+yMPOp11qUSDu/fp+riwpfwQQuhvfxvQ31Fj408FYvUlgk 8z4XJ0VglpKSRnSt8CL1VAkpknPu/jenyUau4IFa/0kpOZwS5IGQ+HYypaeGAbF+ aOW5vQBQ5r5slbd243loDup4ObpWMHn/oyzjpPFmNDn612QP3lGaPm3K3s9GsGZe Yklha8aUlZb9J7MIpIAv5ELeKaIUmF0BfWW77WKwxV8vFwG22aeSu5VIEIVU1+ft FisOtKR4gwD0D0ZA2O5Ij1N5XLUOj+tJjfroCa4ic1rXVyBkc9dqVr8y6dvOamJT xF6qupvRj0AR2cCxjLEj/fVT+ajaw6HG3zy7018n4Kc3n/rjAwaYmSfGJZXHN6M5 jL/E9F3q42E6tgBB6YbCWHk2gAg4hr/DzFvm8teXaBpaVFArOxSF8N6HXxDgqIbr mKI6ZRMGm290iZpp5/6a9VGZSvtCMUNkJZ5vD45nfvHFTFRRKB319EMSvJiYHQTK Osq2CwZg1Et3x/C7GF3pugr23NmD/OtcNRUwSJ5Au5+QEgv9lcm4Rw8dpwuCtope pSm5tkcwiSugnNMkUhlPyh6cK2e3GQieqs+ijp0BPGoxLmGPTVc= =Wo7z -----END PGP SIGNATURE----- --tavpoct2v7do34bb--