Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp993517ybf; Thu, 27 Feb 2020 03:16:15 -0800 (PST) X-Google-Smtp-Source: APXvYqx/oglrttgPCFZE+/N/cWorduSofUv6YbX2T2TMHpIPH2T4W5//uZrZEC4OiAXF2MC0tzps X-Received: by 2002:a9d:5a09:: with SMTP id v9mr2785977oth.214.1582802175191; Thu, 27 Feb 2020 03:16:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582802175; cv=none; d=google.com; s=arc-20160816; b=cA5poKv0Bo8S6R/z79n62XSIzAp1WgmNWld0I6WZQuoppabLgfbzuqYHLTVJEin+ib 4TefR0HqYlk89DjE4Zk0afdLT97c22Mh3/zcoP7lm+vM7Yv4gGNpI2VImBE7B90Zca9O 3cYuqbMg0F0fg1ikOpUtzxIuA8SK/yjE5ZVDDw0RcG7FjMkfbUHPh8BQth8xm1VaZKje Ze13i3QJtLOhS/hf4qbXgbT5DHs6rgMz8uSbmSpHFFtQM1myXBBpRzD3jREDs5TrhU3y Lyfu5MiKsIZpE84RB7nj3xDfJGJUQtZ/c1FmZbfUvwucw9vSvafnyOx80J3MWiTPehNj dsgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=PSPfkAcD4QDEe9iSfKSFzw4oTZNpL0r5C0vE0nEBfi8=; b=cyIcUy+sMoTMkx/Y0kYOFSLqTJrsaA9L0ftKgCt0Y2OrTBlV16Zgk0YssRar1n3ijE VnorB5G/08CrFGRTawymo2tGdywhcbUKe2jdBXIeBRDtO9gfy1OKDiSqwwzBP4fHvu7/ U7jU3c5pyiP4e/K6TFUW+LMvdGo3GOeFUYTp8vJRorHbEMo7XtRKgGfgHo+rbWZMQJJH V+izmlrp/holqlHXE28H9rNWeEV2T0pNQVdBijIrIatijurFpnLpLqDhz0GntQUoBZPH rVEfQ29RRmBcfEfjwL1Z4LoLIO71Iw9HH403LSkzkygjgyJsBazj8wAmGg4HJDfngSIT RsHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@bfs.de header.s=dkim201901 header.b=hZTek6b2; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x197si1151933oix.174.2020.02.27.03.16.01; Thu, 27 Feb 2020 03:16:15 -0800 (PST) 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; dkim=fail header.i=@bfs.de header.s=dkim201901 header.b=hZTek6b2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728873AbgB0LP7 (ORCPT + 99 others); Thu, 27 Feb 2020 06:15:59 -0500 Received: from mx01-muc.bfs.de ([193.174.230.67]:37607 "EHLO mx01-muc.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728759AbgB0LP7 (ORCPT ); Thu, 27 Feb 2020 06:15:59 -0500 Received: from SRVEX01-SZ.bfs.intern (exchange-sz.bfs.de [10.129.90.31]) by mx01-muc.bfs.de (Postfix) with ESMTPS id E1BCE20342; Thu, 27 Feb 2020 12:15:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bfs.de; s=dkim201901; t=1582802155; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PSPfkAcD4QDEe9iSfKSFzw4oTZNpL0r5C0vE0nEBfi8=; b=hZTek6b2Y4HMl5mxHAmJ4zxsXbSz4FzU8KeGrX18+sHYSvU2k5tt2oM0qYHB6psoEXGHFq Uho6MeghLCDarNitxYByWjE2JP2spLWNKY0P6iWggFJHne8qpiCnbqoZuxx8sJvyUTRsUV p0Syd7KVDaU3JtvOgkHmu1xUd8mrvTt6c67MW7fXuwtKRtXS/Ssk2ZVbY9BhmrnvcQAvFh LYSSifQCD2THJP5f4u+Rn2Vwo5g4uv9EkTRAKlNWpFuwzWwCxc1sjscHUiwQ9Hixv0Ab5t wic11wWremaDuctMTYuKnhuouxIcK/5FO69d6XQ18rHZbFwDbQFxjUqwJiodow== Received: from SRVEX01-SZ.bfs.intern (10.129.90.31) by SRVEX01-SZ.bfs.intern (10.129.90.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1913.5; Thu, 27 Feb 2020 12:15:55 +0100 Received: from SRVEX01-SZ.bfs.intern ([fe80::7d2d:f9cb:2761:d24a]) by SRVEX01-SZ.bfs.intern ([fe80::7d2d:f9cb:2761:d24a%6]) with mapi id 15.01.1913.005; Thu, 27 Feb 2020 12:15:55 +0100 From: Walter Harms To: Colin King , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , Gyungoh Yoo , Bryan Wu , "dri-devel@lists.freedesktop.org" , "linux-fbdev@vger.kernel.org" CC: "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: AW: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing Thread-Topic: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing Thread-Index: AQHV7N8n5fHjoG7xokCkDx0n/hJSlagu4ztb Date: Thu, 27 Feb 2020 11:15:55 +0000 Message-ID: References: <20200226195826.6567-1-colin.king@canonical.com> In-Reply-To: <20200226195826.6567-1-colin.king@canonical.com> Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.137.16.39] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam-Status: No, score=-2.99 Authentication-Results: mx01-muc.bfs.de X-Spamd-Result: default: False [-2.99 / 7.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; HAS_XOIP(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_SEVEN(0.00)[11]; NEURAL_HAM(-0.00)[-0.990,0]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; BAYES_HAM(-2.99)[99.98%] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi all, i would suggest converting this in to a more common for() loop. Programmers are bad in counting backwards. that kind of bug is=20 common. re, wh ________________________________________ Von: kernel-janitors-owner@vger.kernel.org im Auftrag von Colin King Gesendet: Mittwoch, 26. Februar 2020 20:58 An: Lee Jones; Daniel Thompson; Jingoo Han; Bartlomiej Zolnierkiewicz; Gyun= goh Yoo; Bryan Wu; dri-devel@lists.freedesktop.org; linux-fbdev@vger.kernel= .org Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org Betreff: [PATCH][V2] backlight: sky81452: insure while loop does not allow = negative array indexing From: Colin Ian King In the unlikely event that num_entry is zero, the while loop pre-decrements num_entry to cause negative array indexing into the array sources. Fix this by iterating only if num_entry >=3D 0. Addresses-Coverity: ("Out-of-bounds read") Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight dr= iver") Signed-off-by: Colin Ian King --- V2: fix typo in commit subject line --- drivers/video/backlight/sky81452-backlight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/b= acklight/sky81452-backlight.c index 2355f00f5773..f456930ce78e 100644 --- a/drivers/video/backlight/sky81452-backlight.c +++ b/drivers/video/backlight/sky81452-backlight.c @@ -200,7 +200,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_pa= rse_dt( } pdata->enable =3D 0; - while (--num_entry) + while (--num_entry >=3D 0) pdata->enable |=3D (1 << sources[num_entry]); =20 int i; for(i=3D0;ienable |=3D (1 << sources[i]); } -- 2.25.0