From patchwork Tue Feb 16 15:49:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 8328641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6C19C02AA for ; Tue, 16 Feb 2016 15:53:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7122202AE for ; Tue, 16 Feb 2016 15:53:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AB3720272 for ; Tue, 16 Feb 2016 15:53:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVhv2-0000PM-O8; Tue, 16 Feb 2016 15:52:04 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVhtA-0006ef-O0 for linux-arm-kernel@bombadil.infradead.org; Tue, 16 Feb 2016 15:50:08 +0000 Received: from mx2.suse.de ([195.135.220.15]) by merlin.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1aVht9-0000UX-0l for linux-arm-kernel@lists.infradead.org; Tue, 16 Feb 2016 15:50:07 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 87AF7ABB0; Tue, 16 Feb 2016 15:49:42 +0000 (UTC) Date: Tue, 16 Feb 2016 16:49:42 +0100 Message-ID: From: Takashi Iwai To: "Arnd Bergmann" Subject: Re: [PATCH] sound: hdmi: avoid dereferencing uninitialized 'jack' pointer In-Reply-To: <1455634059-1896914-1-git-send-email-arnd@arndb.de> References: <1455634059-1896914-1-git-send-email-arnd@arndb.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.5 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160216_105007_371250_FD49A266 X-CRM114-Status: GOOD ( 18.20 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jaroslav Kysela , Mark Brown , linux-arm-kernel@lists.infradead.org, Han Lu , Libin Yang , Thierry Reding , David Henningsson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 16 Feb 2016 15:47:28 +0100, Arnd Bergmann wrote: > > 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") Thanks for the patch. But I think it's cleaner to fix Kconfig. Thinking more of it, maybe splitting jack stuff as a separate module and does reverse-select to CONFIG_INPUT would be better. Then its users can select simply SND_JACK, and everything would fit. An untested patch is below. Mark, what do you think? Takashi diff --git a/sound/core/Kconfig b/sound/core/Kconfig index a2a1e24becc6..cf4058dde959 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -24,11 +24,9 @@ config SND_RAWMIDI config SND_COMPRESS_OFFLOAD tristate -# To be effective this also requires INPUT - users should say: -# select SND_JACK if INPUT=y || INPUT=SND -# to avoid having to force INPUT on. config SND_JACK - bool + tristate + select INPUT config SND_SEQUENCER tristate "Sequencer support" diff --git a/sound/core/Makefile b/sound/core/Makefile index 48ab4b8f8279..d16e2b0ba4fb 100644 --- a/sound/core/Makefile +++ b/sound/core/Makefile @@ -11,7 +11,8 @@ endif snd-$(CONFIG_ISA_DMA_API) += isadma.o snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o snd-$(CONFIG_SND_VMASTER) += vmaster.o -snd-$(CONFIG_SND_JACK) += ctljack.o jack.o + +snd-jack-objs := ctljack.o jack.o snd-pcm-y := pcm.o pcm_native.o pcm_lib.o pcm_misc.o \ pcm_memory.o memalloc.o @@ -41,6 +42,7 @@ obj-$(CONFIG_SND_RTCTIMER) += snd-rtctimer.o obj-$(CONFIG_SND_PCM) += snd-pcm.o obj-$(CONFIG_SND_DMAENGINE_PCM) += snd-pcm-dmaengine.o obj-$(CONFIG_SND_RAWMIDI) += snd-rawmidi.o +obj-$(CONFIG_SND_JACK) += snd-jack.o obj-$(CONFIG_SND_OSSEMUL) += oss/ obj-$(CONFIG_SND_SEQUENCER) += seq/ diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 8f6594a7d37f..32151d8c6bb8 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -866,7 +866,7 @@ config SND_VIRTUOSO select SND_OXYGEN_LIB select SND_PCM select SND_MPU401_UART - select SND_JACK if INPUT=y || INPUT=SND + select SND_JACK help Say Y here to include support for sound cards based on the Asus AV66/AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, DS, DSX, diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index e94cfd5c69f7..bb02c2d48fd5 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig @@ -4,7 +4,7 @@ config SND_HDA tristate select SND_PCM select SND_VMASTER - select SND_JACK if INPUT=y || INPUT=SND + select SND_JACK select SND_HDA_CORE config SND_HDA_INTEL diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 7ea66ee3653f..182d92efc7c8 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig @@ -6,7 +6,7 @@ menuconfig SND_SOC tristate "ALSA for SoC audio support" select SND_PCM select AC97_BUS if SND_SOC_AC97_BUS - select SND_JACK if INPUT=y || INPUT=SND + select SND_JACK select REGMAP_I2C if I2C select REGMAP_SPI if SPI_MASTER ---help---