From patchwork Thu Oct 5 12:08:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9986971 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 CB317602B8 for ; Thu, 5 Oct 2017 12:09:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6BC81FF1D for ; Thu, 5 Oct 2017 12:09:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB557286F3; Thu, 5 Oct 2017 12:09:05 +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=unavailable 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 E0DD228C5F for ; Thu, 5 Oct 2017 12:09:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 12C2B6E7C3; Thu, 5 Oct 2017 12:09:03 +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.126.135]) by gabe.freedesktop.org (Postfix) with ESMTPS id B4C186E7B4; Thu, 5 Oct 2017 12:09:00 +0000 (UTC) Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MBvyp-1e7TcH0AGV-00AmF7; Thu, 05 Oct 2017 14:08:38 +0200 From: Arnd Bergmann To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie Subject: [PATCH] drm/i915: avoid potential uninitialized variable use Date: Thu, 5 Oct 2017 14:08:26 +0200 Message-Id: <20171005120835.437022-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:IGQD19kU3sYz5XeROmYmH4WJha7PaqY+XWQMtM6yne3+j0gji34 syjtJ/Qzlt6GIWKvrATfv1ikG2/MEE521Cvqv0EHsU1J5tAwhG9l+qEk4c1Mb3PVOU2Tnsi UpT6F7oDWz5mtqyzCdM7LYvALPRa5G5NXt20mSN1JCaukyzzZs/YUgXhena0RTqorBoezO5 n01BKrBaaZphJwa+UIMQg== X-UI-Out-Filterresults: notjunk:1; V01:K0:p35m9x/HbOQ=:AHZ0S5xiRPzAgqlRNEC1K9 DeXVnlOaV+tPMPdLty0nhYXkz59ijbwzVU13u+ctmvypE4RIEzxOLPv7w9llzhklX2MHOxzza Dt21rIc8FL7P3VuxNVoseiPc0UBdviv6JEMjzuE4/VMAA/M/mQww15F9VrWAqONaqYMDhkPmx wwKfZ+1YKjimQuzijSaYVTc5iQ/aVOnuSxkiLhMKAxWwtC/gu8osfmTTvcK1r95r4ExfcEeVx WZYubXbu/k9uQFFpfTBlZC3Y43kcbGCnNS7W6ctry/VIGAMPxCJ2YlUnS2wBpvtIEwHdRaPkB PWX2wS8APoTILT59cy+r8HmYmRpvJ9plQTe6Hd4/s1Yf3I8oooggHA8AoT1DkLq9NlyEnR6BJ GZ9oblcwKkie3avd3EohLgtdU+ykyt3RylPo1RQad4rZh4QTYsCLRJXO9C/S8xRkh3+WBzik+ iMXn8drwSvgEzccg0bYQnmFJWY0a1cCIVL7SHxMlExAh29b1GjE/ODEcgdrGt5MyUhIpkB9aX t7+rYYu5n66Xvt5ABeQqxh92Nconma2hsjHTLKcdyLg3bno68wC5X5H+W+qQB1zQWIzodKYJ7 OohjwXPg70ZxzUeG/SE1ly0cirJb7AAG04DoV9KlHjQ50hJfP3XVadLDXDsiK8EIu3y0FHLnC V8Mr5qSlJs4oXF1wkOBFWq6eV7nB3PiPQmvehGheeZ+sGjMixvt3RkwvLZjBQbilTceEhgk41 V9kN6XFgCbLJStlykmMOMIPCrB8/Qamv+KAN9w== Cc: Ander Conselvan de Oliveira , Paulo Zanoni , Arnd Bergmann , Tvrtko Ursulin , Daniel Vetter , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org 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 One of the recent changes introduced a warning about undefined behavior in the sanity checking: drivers/gpu/drm/i915/intel_ddi.c: In function 'intel_ddi_hdmi_level': drivers/gpu/drm/i915/intel_ddi.c:654:6: error: 'n_hdmi_entries' may be used uninitialized in this function [-Werror=maybe-uninitialized] It seems that the new cnl specific get_buf_trans functions can return uninitialized data if the voltage level is set to an unexpected value. This changes the code to always return '1' in that error case, which seems like the safest choice as we use one less than the number as an array index later on. Fixes: cc9cabfdec38 ("drm/i915/cnl: Move voltage check into ddi buf trans functions.") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/i915/intel_ddi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index 93cbbcbbc193..d0b786078bea 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c @@ -602,8 +602,10 @@ cnl_get_buf_trans_hdmi(struct drm_i915_private *dev_priv, int *n_entries) } else if (voltage == VOLTAGE_INFO_1_05V) { *n_entries = ARRAY_SIZE(cnl_ddi_translations_hdmi_1_05V); return cnl_ddi_translations_hdmi_1_05V; - } else + } else { + *n_entries = 1; MISSING_CASE(voltage); + } return NULL; } @@ -621,8 +623,10 @@ cnl_get_buf_trans_dp(struct drm_i915_private *dev_priv, int *n_entries) } else if (voltage == VOLTAGE_INFO_1_05V) { *n_entries = ARRAY_SIZE(cnl_ddi_translations_dp_1_05V); return cnl_ddi_translations_dp_1_05V; - } else + } else { + *n_entries = 1; MISSING_CASE(voltage); + } return NULL; } @@ -641,8 +645,10 @@ cnl_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries) } else if (voltage == VOLTAGE_INFO_1_05V) { *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_1_05V); return cnl_ddi_translations_edp_1_05V; - } else + } else { + *n_entries = 1; MISSING_CASE(voltage); + } return NULL; } else { return cnl_get_buf_trans_dp(dev_priv, n_entries);