From patchwork Tue Feb 16 14:47:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8327281 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5467B9F38B for ; Tue, 16 Feb 2016 14:48:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 720C42027D for ; Tue, 16 Feb 2016 14:48:23 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 24D0920259 for ; Tue, 16 Feb 2016 14:48:22 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id C965E265862; Tue, 16 Feb 2016 15:48:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8834C2606EB; Tue, 16 Feb 2016 15:48:13 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C82282608BC; Tue, 16 Feb 2016 15:48:11 +0100 (CET) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by alsa0.perex.cz (Postfix) with ESMTP id B788C26067A for ; Tue, 16 Feb 2016 15:48:04 +0100 (CET) Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue003) with ESMTPA (Nemesis) id 0MKuxg-1aVgum0j1E-0001Ts; Tue, 16 Feb 2016 15:47:44 +0100 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai Date: Tue, 16 Feb 2016 15:47:28 +0100 Message-Id: <1455634059-1896914-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:sHCnwdz1Dt91eFJMOH53KA2tcueyD0MI/s5v8uC5ps6IhBQx++o VeimzQ2urSsv071RlwJGpVmO2WkkfGAqjhGWzjq+WA0zwtfkV2rTGunWnOTReMVSnR+ojv7 eaHutFDlBIC4HAHDgmDCcDSCsDgJzxNfji1vAU0aWrkGfikW8rcRomeX+MSn/Wk3/6XO0RP sS9EXa3QBN+J/iQkuR0Cw== X-UI-Out-Filterresults: notjunk:1; V01:K0:Vk1W4ylO94E=:VZnfNMLmLYALp6aOP+HEqK vCgQKfRXLMshu9B6wQAXdJJzEPsfZX+8JVQQqba5zfbX8wtHfPgn2ZT77SR8kvaH4RWoDZdkU 2JL/w0wK57xbs8jvOrfjzbTDkazi97dz8i0Q/N5ozZ1clW/yAIA372oTOOSnfN0nmoQD4s/fc qkKC/cRPtDD/Pahb28eePvd5W42xCG2zrzXt37oDlgig+L+ZRHXWpft1wJdX0XT1bqKKodw3m QhebSP0TPWdViDHpCzAVDom6HeMjw8BzyagO2oES5J2UPWVdJxvly8GU3YywyJicvwG1JCPT/ SXPp1tUtoYwlv+0GYnAUp9oExl8wUpc+8Fb2HXtmPiI8rMH2F3e+FWrDbtAZ7bU2nlXWOSkXQ 1qYy07K+HoTrL4DqaVtTVwcNOmsLA3lHqvsPN4vEJLaNqB1HXvqU2DKolQ/hfgZxYAUMmyTPl F4BbZQ4ctLwmUoh21e8ancbE1+BqIJ0Mh88X0i7EENN+qBsN7lYNLVtUGiBAyUv3wTSXnDeSn li/c4JQnNOMRShSaHMYozjpLEQBUvK6ruLu/qiARm1rJbgxGGP2ioODqGyF9djas4DWPSW4WF wLp5n+tIq1fWb4UCJUEIIBnf+BvpkU+XK/Qzb3IW/3mlJ/QMFD+8WuiHDcNs95SqUW4nsD1Ar 8+RR950IDohAz1/mJWorq2cxMUDX4JPewencSttXheipzERt3CeOpyLtNw6NNd5ywxvA= Cc: alsa-devel@alsa-project.org, Arnd Bergmann , linux-kernel@vger.kernel.org, David Henningsson , "Lu, Han" , Libin Yang , Thierry Reding , linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH] sound: hdmi: avoid dereferencing uninitialized 'jack' pointer X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP When CONFIG_SND_JACK is disabled, the hdmi driver tries to create a new output jack structure and dereferences it even though the pointer is never assigned: sound/pci/hda/patch_hdmi.c: In function 'generic_hdmi_build_jack': sound/pci/hda/patch_hdmi.c:2534:30: error: 'jack' may be used uninitialized in this function [-Werror=maybe-uninitialized] sound/pci/hda/patch_hdmi.c:2526:19: note: 'jack' was declared here This uses a compile-time check to avoid calling a nonworking snd_jack_new() function, and sets an explicit NULL pointer instead. Signed-off-by: Arnd Bergmann Fixes: 788d441a164c ("ALSA: hda - Use component ops for i915 HDMI/DP audio jack handling") --- sound/pci/hda/patch_hdmi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index f4443b5fbf6e..c0872ad80aa0 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2526,6 +2526,11 @@ static int add_hdmi_jack_kctl(struct hda_codec *codec, struct snd_jack *jack; int err; + if (!IS_ENABLED(CONFIG_SND_JACK)) { + spec->pcm_rec[pcm_idx].jack = NULL; + return 0; + } + err = snd_jack_new(codec->card, name, SND_JACK_AVOUT, &jack, true, false); if (err < 0)