From patchwork Mon Dec 4 14:53:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10090577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E5FF60329 for ; Mon, 4 Dec 2017 14:54:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F87728595 for ; Mon, 4 Dec 2017 14:53:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6331928E42; Mon, 4 Dec 2017 14:53:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04BD728595 for ; Mon, 4 Dec 2017 14:53:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7931A6E367; Mon, 4 Dec 2017 14:53:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5664F6E367 for ; Mon, 4 Dec 2017 14:53:55 +0000 (UTC) Received: from wuerfel.lan ([149.172.96.106]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0MGR4S-1eHSGZ3Wuu-00DFtg; Mon, 04 Dec 2017 15:53:47 +0100 From: Arnd Bergmann To: Philipp Zabel Subject: [PATCH] gpu: ipu-v3: prg: avoid possible array underflow Date: Mon, 4 Dec 2017 15:53:35 +0100 Message-Id: <20171204145347.597518-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:XntVzk4UHgboyykylPMDPh7qmET4dTy5XaodR6Lu7ME0b222Il5 gV6CqdloU0X5Uhc/WSqZc+AALrMX3QMOEy8AXAjhyAez+IJVNjUG/aA8GmLf2f5cA+LYdYj 7SbSe/IEWDiuiVPqExallx6dHOvq7w7lGnkYO/auLaJfhNZ9wl9ydA4eprcaMC0f06hRxnJ GMsdFEXBP3Q+LU9yoD4/g== X-UI-Out-Filterresults: notjunk:1; V01:K0:SBkRoq2UCGk=:t61Tn0EXhJ9EuZ4rUCJFJg XnmxEFilqLzdqI1sYil1qVbM0RWx1+SgHqqUC3csfOuuxzYLkpssbixggA3La+AFNbAp9gn38 nP8fkl0MbnpnV0lfiMIdGnnn+yvCip4qA4nX3kx0IxAoam/GgS+W74d5HpIoeKAaL2TjhZ4Zv mUyzMwR3jeU3Z7Gaxvwd5V/efrNOh/GOs/GS+aTVnQZN7zs3khaqZl/EQxfr0rs6CDfp9NGaO 1yAy1G+BSs132w0rIZ6B/ux/odNLeShnsIMo8paH24K8elmTNIAVuVxd8D/i4Jlg8zoLmcIEM w1TaQjtMMvwH2BhG1Zlf5kPgNyCKPMf4S+vgp3N/ZvLOl5oBwyr89Z/szyviDWr53a4IjMgq8 U62NUT9/Y+G6dWfRIGH4gH/QoWu3MMOprlRwNLp5kZrZjCzx9eB+xb6aXvPlxNP7fZhI5NM9V a8ZwG8izTmtJa+t9t+NwAFWIwuJqaY5BgLJIANqf4ZMOsqYFiiEPULodnDj/yP1eOuPqhYwpl KDBOUrIfL4/36CiqbpD1MSrzxO1/WOz2619npjmqkLScvr+asijjzMRmWitte2nWM5m8Nhyhe 66pLPCN1gQ61WbpxVMGgSvXJYQmlowPYG9UrwnzMaRrYXm1Q+NeWK376RUnVGR2YoXIDECgNv OJBbTHnOBfkh9K7fZqqhPhpzsaEsgVGo1fe8hAXAhcgIxsTg0dGQzBWvow9yQLk2ecVvrC1ss DSbAlbQCE/6UxVgr8EfprpIXMJyMEVxK/SiOqA== Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Arnd Bergmann X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/gpu/ipu-v3/ipu-prg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/ipu-v3/ipu-prg.c b/drivers/gpu/ipu-v3/ipu-prg.c index 0013ca9f72c8..1417db856989 100644 --- a/drivers/gpu/ipu-v3/ipu-prg.c +++ b/drivers/gpu/ipu-v3/ipu-prg.c @@ -252,7 +252,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; clk_prepare_enable(prg->clk_ipg);