From patchwork Tue Jan 16 14:31:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 124723 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1033420lje; Tue, 16 Jan 2018 06:32:21 -0800 (PST) X-Google-Smtp-Source: ACJfBos32F2gWfA5z20ghem/6JiVZ+4KpiLEyGHfJKNIECCgVtDAIRuUbsofEhHotUOaIzT+5JR+ X-Received: by 10.84.232.197 with SMTP id x5mr30389053plm.80.1516113140858; Tue, 16 Jan 2018 06:32:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516113140; cv=none; d=google.com; s=arc-20160816; b=lqbyMbIibNCGfBdMbZM2SOTcdV+7mMXI5WBEq2ugGyNnbO3y+Xxds5aK2xWpfX/xZO t73BXrKs5vfGMhO84YjkIbNDuKyEibnpbGCNvMgbdd66tPoAdW/LNALPrEmthjYPGdCR VpNeeFA6boNICQOrgWn25J1I9c//6OvT/5FbsTapa5/Y8J3pGRycNoLMGmm6AkTFiskb pEAu+Ap9xTUHZFN7lxQzRJE5WeWnMhJrCcU3U6HExvUdRFKEA6YRN5tFv1P2aQRkhO0D opma9oqCv8DFxAkOHKzMfe7o66BsQ54w3Alws9Epa2dPP+B8MnxXNywFMD889l1Tc81h VGjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=At8oCNxFUr1HWxR3NP31k/YhWUmAyhTRsxua7VTT6jY=; b=iowFIzj95x1ZwIIaJDJvjvwDqm1/QjCX7JZldTW4DpiDZogQkM8xFpHBWKlGS/1rd8 7BGgDW6OYmSlbOQHo0exfisjXkF5ghpOy6/auiHMVPVx73qEaVnbt4cHjvEN/JF105kp HBl4IiSIUZolVlh+69qaMcJHmo3PQknfnOArNZloXmzOeEpQePS7f5y7PW5Oyx25g4uh xa/WccOkCiNLUMJFtTsJFuVZCo5elNO+EB/8hSjQTmT4siW4gMEiZpt3WL39ZdbEDbpU YjyWsNV0bXTMANZgp833+y8B7js5Um44InokCDXrqL9TrkM0yTT0Zo4mgffW/pjO5AxR SfiQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u77si1996822pfd.165.2018.01.16.06.32.20; Tue, 16 Jan 2018 06:32:20 -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; 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 S1751394AbeAPOcS (ORCPT + 28 others); Tue, 16 Jan 2018 09:32:18 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:62879 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750905AbeAPOcR (ORCPT ); Tue, 16 Jan 2018 09:32:17 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0Ma2mt-1eGLA21F0R-00LlgJ; Tue, 16 Jan 2018 15:32:13 +0100 From: Arnd Bergmann To: Philipp Zabel Cc: Arnd Bergmann , Lucas Stach , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] [RESEND] gpu: ipu-v3: prg: avoid possible array underflow Date: Tue, 16 Jan 2018 15:31:55 +0100 Message-Id: <20180116143212.1411334-1-arnd@arndb.de> X-Mailer: git-send-email 2.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Hoqaw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc-8 reports that we access an array with a negative index in an error case: drivers/gpu/ipu-v3/ipu-prg.c: In function 'ipu_prg_channel_disable': drivers/gpu/ipu-v3/ipu-prg.c:252:43: error: array subscript -22 is below array bounds of 'struct ipu_prg_channel[3]' [-Werror=array-bounds] This moves the range check in front of the dereference. Signed-off-by: Arnd Bergmann ---- Originally sent on Dec 4, 2017. No reply, so resending unchanged. --- drivers/gpu/ipu-v3/ipu-prg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 diff --git a/drivers/gpu/ipu-v3/ipu-prg.c b/drivers/gpu/ipu-v3/ipu-prg.c index 067365c733c6..0bcb935e525c 100644 --- a/drivers/gpu/ipu-v3/ipu-prg.c +++ b/drivers/gpu/ipu-v3/ipu-prg.c @@ -250,7 +250,7 @@ void ipu_prg_channel_disable(struct ipuv3_channel *ipu_chan) struct ipu_prg_channel *chan = &prg->chan[prg_chan]; u32 val; - if (!chan->enabled || prg_chan < 0) + if (prg_chan < 0 || !chan->enabled) return; pm_runtime_get_sync(prg->dev);