From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFECFC4363D for ; Mon, 5 Oct 2020 13:50:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 794E4207BC for ; Mon, 5 Oct 2020 13:50:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726105AbgJENuu (ORCPT ); Mon, 5 Oct 2020 09:50:50 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:56702 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbgJENuu (ORCPT ); Mon, 5 Oct 2020 09:50:50 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 30C841C0B77; Mon, 5 Oct 2020 15:50:47 +0200 (CEST) Date: Mon, 5 Oct 2020 15:50:46 +0200 From: Pavel Machek To: Marek Behun Cc: ultracoolguy@tutanota.com, Dmurphy , Linux Leds , Trivial , linux-kernel@vger.kernel.org Subject: Re: [PATCH] leds: lm3697: Fix out-of-bound access Message-ID: <20201005135046.GA26765@duo.ucw.cz> References: <20201005141334.36d9441a@blackhole.sk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="n8g4imXOkfNTN/H1" Content-Disposition: inline In-Reply-To: <20201005141334.36d9441a@blackhole.sk> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > > if (ret) > > dev_err(&priv->client->dev, "Cannot write OUTPUT config\n"); > >=20 > > - for (i =3D 0; i < LM3697_MAX_CONTROL_BANKS; i++) { > > + for (i =3D 0; i < priv->num_leds; i++) { >=20 > Ultracoolguy is correct that this for cycle should not iterate > LM3697_MAX_CONTROL_BANKS. Instead, the count check in lm3697_probe should= be changed from >=20 > if (!count) > to > if (!count || count > LM3697_MAX_CONTROL_BANKS) >=20 > (the error message should also be changed, or maybe dropped, and the > error code changed from -ENODEV to -EINVAL, if we use || operator). I guess Dan (or someone else?) can submit simple one-liner I could apply into -for-next (and maybe stable), and then we can sort the naming etc in the driver? Gettings banks vs. LEDs right would be nice. Thanks and best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --n8g4imXOkfNTN/H1 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCX3sktgAKCRAw5/Bqldv6 8nn/AJ9plJ17mUe1BmlOkkLDOrp60YN95wCgitYQ9BT4aZATHV5sfkRBbnCA9lM= =xGtn -----END PGP SIGNATURE----- --n8g4imXOkfNTN/H1--