linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-arm-kernel@lists.infradead.org,
	Arnd Bergmann <arnd@arndb.de>,
	Libin Yang <libin.yang@linux.intel.com>,
	David Henningsson <david.henningsson@canonical.com>,
	Thierry Reding <treding@nvidia.com>, "Lu, Han" <han.lu@intel.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sound: hdmi: avoid dereferencing uninitialized 'jack' pointer
Date: Tue, 16 Feb 2016 15:47:28 +0100	[thread overview]
Message-ID: <1455634059-1896914-1-git-send-email-arnd@arndb.de> (raw)

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 <arnd@arndb.de>
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)
-- 
2.7.0

             reply	other threads:[~2016-02-16 14:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 14:47 Arnd Bergmann [this message]
2016-02-16 15:49 ` [PATCH] sound: hdmi: avoid dereferencing uninitialized 'jack' pointer Takashi Iwai
2016-02-16 16:09   ` Arnd Bergmann
2016-02-16 16:18     ` Takashi Iwai
2016-02-16 16:38       ` Mark Brown
2016-02-16 16:43         ` Takashi Iwai
2016-02-16 16:59         ` Arnd Bergmann
2016-02-16 17:09           ` Arnd Bergmann
2016-02-16 17:10           ` Takashi Iwai
2016-02-16 17:26             ` Arnd Bergmann
2016-02-16 22:08               ` Arnd Bergmann
2016-02-17  9:03                 ` Takashi Iwai
2016-02-17  9:24                   ` [PATCH] ALSA: jack: Allow building the jack layer without input kbuild test robot
2016-02-17  9:35                   ` [PATCH] sound: hdmi: avoid dereferencing uninitialized 'jack' pointer Takashi Iwai
2016-02-17  9:40                     ` Arnd Bergmann
2016-02-24 16:18                     ` Arnd Bergmann
2016-02-24 16:25                       ` Takashi Iwai
2016-02-24 16:39                         ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455634059-1896914-1-git-send-email-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=david.henningsson@canonical.com \
    --cc=han.lu@intel.com \
    --cc=libin.yang@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).