From patchwork Tue Mar 23 13:05:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406872 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4434236jai; Tue, 23 Mar 2021 06:05:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb4y/YkYJs0QaI772TCMZWIFtM2Vr5PZSwYFuwYgqQJw1h/s6Yzra31r3BhgB19P4mShbU X-Received: by 2002:a63:1921:: with SMTP id z33mr3993837pgl.211.1616504757638; Tue, 23 Mar 2021 06:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616504757; cv=none; d=google.com; s=arc-20160816; b=ghw9cBOeIHNrZJPY5p7dCMd5NbJS44/ptUg0WPSlpoUwQZP2QGuMa95sz1gv5WK65q LX80qPds1XgbgyYLYiB67x43C8FFS4ppDgzsB6S6SM/+84RWYS97LMrRO3r4EXDIAmFY UExPLkXY6fbFE0K0vm6pJyXEKqSgNXHl4InP4qAjgo1DHHfUHLjw0Of3sNEgNBJmG3fK f8Gn/bvIcn5NeksRwfKAxoiNbKLM5w3R3XEYz0hOs/IMiTa3qHYrNLzE//jz+UbOONSN aMamxZuKFf+STk0m+lXcCkOOEqYqF1sLRhMLQlxjYWgPCzVWiGW5WDyluH6QZ+CHmXpR 0eUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=Natq9XIENenpiZYSfA6g51rn612zJMZBU0eYdaaxRRc=; b=i5PZUQ20SnNgbPEFUeM5TJ8XcPEyiU/LYz9f7ShlF9uNoKvhbg+MvDECermcOeKBsS NtMiID7cBlziSDzEXhXt4kPIfXtdQ0Dh6SfZZnyujnA4OHl/1IGt9AKBAjTYufAG5TIA rzKzdi+TO12MarCse9RUXRuC2we2XnqoNc1sVEEmJhHc6pfNwZNQxzQotTECGld1sawV dUnpS+AGKBYpSTfZOynzLpdwGMpA0R2sAJCJEEGS3/S0nqTx2eXqzndHpvfkgGtGQ6Xt uI5LyqUtWNbmP+lAzI3xxwWQsxyE8e89hMGvxfQZO9TMUCAm7oN/fJ3B4jNRO+Dh4gsc 49Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=sXjI8Rlq; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id ls16si2919851pjb.143.2021.03.23.06.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 06:05:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=sXjI8Rlq; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 885C86E85D; Tue, 23 Mar 2021 13:05:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9664C6E85D for ; Tue, 23 Mar 2021 13:05:55 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 4D5E8619B6; Tue, 23 Mar 2021 13:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616504755; bh=LElXukqBYdsmTv2ghODVkHwAAvlW3HFLLVGUeIbz0OA=; h=From:To:Cc:Subject:Date:From; b=sXjI8RlqjbU1oQkovu2toiAAKvGF09MicfaIGV9KdrzoOBNGDfaX4rOLl3/lwhBs6 r1zfIZXObRqW2n9r1Z1c6kymwz3x/+NwLIPTbWdk1Jfoxu6A2eqxwcGHBHPiHygIfu agCLOTf4Q4zuJlTVal8rYO3E9aeVVCx17MWH6d26QMjBiPUMi0Zxc1bfAo3cLv4yhV 4qGVwB7Qv0KVzLNLtsk46ehVDlQ9A9IPZBq3u8t/engD007SKu3f8c2Z7oBINnHQ0u 9jPfjcsb7aauRsuAYKBb4uJcqhHUaSs8mkOgG1CTmLDLi86XBZ8TV9eYPBSCAnQqCR acNGOM+BBihyg== From: Arnd Bergmann To: Philipp Zabel , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer Subject: [PATCH] drm/imx: fix out of bounds array access warning Date: Tue, 23 Mar 2021 14:05:43 +0100 Message-Id: <20210323130550.2289487-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 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: Thomas Zimmermann , Arnd Bergmann , Liu Ying , Marco Felsch , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , Joe Perches , linux-arm-kernel@lists.infradead.org, Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann When CONFIG_OF is disabled, building with 'make W=1' produces warnings about out of bounds array access: drivers/gpu/drm/imx/imx-ldb.c: In function 'imx_ldb_set_clock.constprop': drivers/gpu/drm/imx/imx-ldb.c:186:8: error: array subscript -22 is below array bounds of 'struct clk *[4]' [-Werror=array-bounds] Add an error check before the index is used, which helps with the warning, as well as any possible other error condition that may be triggered at runtime. Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/imx/imx-ldb.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c index dbfe39e2f7f6..1210360cec8a 100644 --- a/drivers/gpu/drm/imx/imx-ldb.c +++ b/drivers/gpu/drm/imx/imx-ldb.c @@ -197,6 +197,12 @@ static void imx_ldb_encoder_enable(struct drm_encoder *encoder) int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder); + if (mux < 0) { + dev_warn(ldb->dev, + "%s: invalid mux\n", __func__); + return; + } + drm_panel_prepare(imx_ldb_ch->panel); if (dual) { @@ -255,6 +261,12 @@ imx_ldb_encoder_atomic_mode_set(struct drm_encoder *encoder, int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder); u32 bus_format = imx_ldb_ch->bus_format; + if (mux < 0) { + dev_warn(ldb->dev, + "%s: invalid mux\n", __func__); + return; + } + if (mode->clock > 170000) { dev_warn(ldb->dev, "%s: mode exceeds 170 MHz pixel clock\n", __func__);