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=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 43317C4BA3B for ; Thu, 27 Feb 2020 11:46:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17ABE24693 for ; Thu, 27 Feb 2020 11:46:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="f6IaWn5/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17ABE24693 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF70E6E84F; Thu, 27 Feb 2020 11:46:28 +0000 (UTC) Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id A82446E84F for ; Thu, 27 Feb 2020 11:46:27 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id r7so647072wro.2 for ; Thu, 27 Feb 2020 03:46:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=cTBJSroA9RJ+8lBEwYkKnNGeXoVHBYBbqwTPMLg2F9o=; b=f6IaWn5/yo6zdY5X0ONlrcO/16bC0jHGTfMt38t7p56Jk/StSR2GrXddKXOery9A+q bsjgvdrg9L2Y5X/z9mPZ40VcKxSzvjl/BcWiURUpE3UAHihkGE+aNwqW/hQHYlzJgTgZ dfkiTG5kuvTJCd5dwZrlgZojGkh2FdtDn/Motiqg1mztRnu9q46TLh5KM8w8xNboLfWi 8CDE32ktJ+g+I1TZDeJIVMR3WVojdFKmDI2+8Me3bjD1iR73YZ3bq3EhQ9l8C/B8ULlL F/KJj4448hTB1c4I+t6S2FwLOa1EMsR98TeyclEAn/s0Obty8TAwe9cBsru+gLOVAy96 nLug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cTBJSroA9RJ+8lBEwYkKnNGeXoVHBYBbqwTPMLg2F9o=; b=OymQZ3uBGOZU4GVYMSde9bAo+EYry1va/J1dW6o5C2dr3zGZNAPK1Wd7kV/HpwcmEt 6NkjuORMU+ONwb12QDclNGYldF0Bpko5YUeRXpA+W/h7p8hTsrhYOXcnuBjH/lsOBxOf yMJlVtylOnFkt+NnF8rP0mR+J0gRSjqXqeI2sK8jxkNlRmQVJE9dCC1yIbMrPdipkeTe YSSGH/hAGoD5OLgvqVVpYDkpWg+2rDjDJWjFhtaOyneA3nUOfpb04hseqw+wsf2wBE/3 FSBxUtFKIIGhi/gWH95h3Uk+toPeXfesmdONWzXT0gGa3jmJsXJ9xZFj/vfRuJjTLEDs HYsg== X-Gm-Message-State: APjAAAWwr4jL7VrNNJOTA+1N80stdhnBsyVEATCCKDx0QF1NbPAY1bhr GuOAGDW0y0QFRAtVAOVkAuYC0w== X-Google-Smtp-Source: APXvYqz1InEhOPcHB1heYSDPHQuazWq7emWdftcDiZpOvuTUa9UVkpntp5/WkSSXkFxYObe7pXC9kQ== X-Received: by 2002:adf:efc4:: with SMTP id i4mr4509410wrp.225.1582803986345; Thu, 27 Feb 2020 03:46:26 -0800 (PST) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id 133sm7667950wme.32.2020.02.27.03.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 03:46:25 -0800 (PST) Date: Thu, 27 Feb 2020 11:46:23 +0000 From: Daniel Thompson To: Colin King Subject: Re: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing Message-ID: <20200227114623.vaevrdwiduxa2mqs@holly.lan> References: <20200226195826.6567-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200226195826.6567-1-colin.king@canonical.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , kernel-janitors@vger.kernel.org, Jingoo Han , Bryan Wu , Gyungoh Yoo , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Lee Jones Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, Feb 26, 2020 at 07:58:26PM +0000, Colin King wrote: > 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 >= 0. > > Addresses-Coverity: ("Out-of-bounds read") > Fixes: f705806c9f35 ("backlight: Add support Skyworks SKY81452 backlight driver") > Signed-off-by: Colin Ian King > --- > > V2: fix typo in commit subject line Isn't the correct spelling "ensure"? > --- > 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/backlight/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_parse_dt( > } > > pdata->enable = 0; > - while (--num_entry) > + while (--num_entry >= 0) > pdata->enable |= (1 << sources[num_entry]); This look still looks buggy to me (so I'd second Walter's request to change it to a for loop). If the code genuinely does not contain a bug then it probably needs a prominent comment explaining why it is correct not to honour sources[0]! Daniel. _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel