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: 10167217 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 F39C260325 for ; Tue, 16 Jan 2018 14:32:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8652328396 for ; Tue, 16 Jan 2018 14:32:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AC1D28438; Tue, 16 Jan 2018 14:32:18 +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 1B98928396 for ; Tue, 16 Jan 2018 14:32:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F04FF6E254; Tue, 16 Jan 2018 14:32:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 2802 seconds by postgrey-1.36 at gabe; Tue, 16 Jan 2018 14:32:15 UTC Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 921C26E254 for ; Tue, 16 Jan 2018 14:32:15 +0000 (UTC) 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 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.9.0 X-Provags-ID: V03:K0:AJXVsjfJ4tzH74zQGfovJvjghKhzETwIlc3cC1VfSneaWcaJHQF 4q2HUjt1JEH0FVe0RDmWEFalS4m8sx9OTpBBkgCOxthgQ5haWWqbrnf3V0a7lBl97RWe+wU LaEHDnwtQmrGkmKmD+6MrfDR+JAH90Of8FiQnQJr5pDqpiB9UUZBObe4/qJvJf9Y0P2G5LJ T5KJCCB0FMh8RsutpUsjw== X-UI-Out-Filterresults: notjunk:1; V01:K0:f+bx5sdt0r0=:C+uCMMv69e2sy6c7FX++sp /twZe6W4nccJOj6nN8PkTTaPPeIrzNRR7tDlzuBYV1LmcptasRZq5rV55T54kdOBZ57C9EM7i fjRl9LN4DelO2NrlGY5hh7tag94mYfwGXdzL2h5FvQ0WiV/5+Tbv0UZhmXHmZ8QBVkuBhFSk2 w55qFLVTc4lUiB6QRbebRrbLGOMMtuceyBvT9ZSpz8y+n1PG/V+vrek/MI6TuEDl5ov8U2+kI BAfKf0q1FvsRHNhoi/QpXppxDU9bOs9bZnwbPFokdUXVMWYEcrx7AWXa692AnfhlWaXR40u1G nZuCTYwlAjBQUV/hFkwnH4o1hRPjTf2QBn0Ehm3R4P3I2jZ3HpiM4wiRgC+rN2CDgPNcd0cnb yOv5Unzqjp6EvzabAkrz/qJuDKo9jEjTrn2vWbUtUwpJO3u2Xg34qHFGaZQNBLqwJDF17CvZq fm5tuLRqloWZjqdFjcdnyBcYCE0TwcEms2SazUXKwUyRiMoPrw9Yk2XVkdVOkIZfgxqFV/+fY L73RpKR4qz7Mycmmfs8ncXHj8GZQ5d3q9qzCWdkV634V+AvUiqCxrbeBQdsbozXMRJju4Qubp RIawLILptrllF86mJkTFkioQFyZ7TV7W8+UWOzKQ/qyE92ASSZpobDZqJvfWCjyHzeIKpb0EL bV6rAHffSFmkFf2fxHSeuJEXHtMMRSxlPNO6P1aiwaZStgGX9RAB+3Z6AsNj/5CUtqQcx6VXS lv/e3IKS3FSmvoZUcv+pL2WxV9ocbkL1GHoqaw== 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 ---- 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(-) 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);