From patchwork Tue Feb 16 16:59:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8329581 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 4C3969F38B for ; Tue, 16 Feb 2016 16:59:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D8E02027D for ; Tue, 16 Feb 2016 16:59:42 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3A5DE20256 for ; Tue, 16 Feb 2016 16:59:41 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9CD9C2658CB; Tue, 16 Feb 2016 17:59:39 +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,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A596E2610B0; Tue, 16 Feb 2016 17:59:31 +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 9751D2655DB; Tue, 16 Feb 2016 17:59:30 +0100 (CET) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by alsa0.perex.cz (Postfix) with ESMTP id 859EC2608BC for ; Tue, 16 Feb 2016 17:59:23 +0100 (CET) Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0Lwioi-1ZuQC52i9g-016Rpb; Tue, 16 Feb 2016 17:59:09 +0100 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Date: Tue, 16 Feb 2016 17:59:04 +0100 Message-ID: <112888486.mQgaWiH0PI@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20160216163840.GA7544@sirena.org.uk> References: <1455634059-1896914-1-git-send-email-arnd@arndb.de> <20160216163840.GA7544@sirena.org.uk> MIME-Version: 1.0 X-Provags-ID: V03:K0:zxOY2R7ocz901IMQAKL+i0WK+rfHQ6QIGrAcG7yddsFC8NWZDhp qQWPaBuBe3pBbCFVtTKn68XAnrW8ccUFqD+2ilRukxolznf0K1TQtPliF9zIytl1ibnWb9Z RH7W07obtZ+ZyEfPhRxC+jXCLaSgPK7hbYxzLOUqcjN7dk36KqeuTR51hr84PWbuUnUfOpJ kU93dR32a2Bg+u09gIqWg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Kb/fng5y0HI=:1/LjvLLidekDdVYA1WEcZQ S7MhFeAotGw0NRBhS4X7uXGLqlw8tmCoA0RnoI9zPSC7HTj/0JSfj3JwrOrzjUZF+DaiEF1ye q9M5ZWRgsvO1o2vLwzim/HspaPHSHEgGpljH7BGKU+T1Bk6eP6xI6S7qXOzWuoiunPqk/oM7T MgDX69N3GT0p1NHZfrzoQhY9kCAWXGtTgODQYdVU08RpNP+vGdqDjU8KUMPD8XXvCMO831bGy k7g2a4WCHl4Mkm38e6j+qidIqYJCyV6XBvgGLnXLB8hrjps3U2mmdwKavaNyeU8KulqWzIcJT Tfj0wcZRgljreuvYP21/rHbXNNgNwdMSRC1TDrXxRJ4nGMHasGNzh4ntS9rkmTDZ7zzwY1uLM huLAEvqOesu0tqNISju4nIUmWLDzr1UgrGHTN9OJ8xsoD0cHUxIJF3l/PQI/1eE2jnoNGm/+q 2iaR/imGdy6BZ1e1Uj8sLeNqA6nzEblSYmcmL3rvHxUpuu5YLvb3OrJ1fKQlN6j0iSfTFnNMa cr9zHqnIxpHpNpJgPLmEnJOMHQRX9X09SgiihwWRWF3WfDuKlhQWZ4FfudbgWFssK9Y4hEPEC Bp39tSrM00d7ITnhyIPXy03HS7ZtiSazwfECrk7EqjZ5KgZmiXiQhVnOm9DW5F0jNAhyUpv1y v3p1f+wkb60fdTu+gAmJCJe3gztGTZcHM2TZaXpU06jZEX13VykaTfNyy7bVrQLblNjAIA16R 1HD0azjUoSX3u2FG Cc: alsa-devel@alsa-project.org, Takashi Iwai , linux-kernel@vger.kernel.org, Mark Brown , Han Lu , Libin Yang , Thierry Reding , David Henningsson Subject: Re: [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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On Tuesday 16 February 2016 16:38:40 Mark Brown wrote: > On Tue, Feb 16, 2016 at 05:18:29PM +0100, Takashi Iwai wrote: > > Arnd Bergmann wrote: > > > > Another option might would be to change snd_jack_new() to return > > > an error if that SND_JACK is disabled, and then require all users > > > to handle the error gracefully, i.e. not fail the probe() function > > > but just not use the jack. > > > Yes, I thought of that, too. If select is no good option, it's a good > > alternative, indeed. > > It's going to be a bunch of work to implement though. > I've already sent a v2 to change the snd_jack_new() function, feel free to ignore that. I also saw now that the same bug is present in hda_jack.c, but I think the other drivers are fine. How about this approach below? That should also make it possible to use the jack APIs without using a error return. Arnd diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index a33234e04d4f..2f72b3c09d92 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -403,8 +403,10 @@ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, jack->phantom_jack = !!phantom_jack; jack->type = type; - jack->jack->private_data = jack; - jack->jack->private_free = hda_free_jack_priv; + if (IS_ENABLED(CONFIG_SND_JACK)) { + jack->jack->private_data = jack; + jack->jack->private_free = hda_free_jack_priv; + } state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0); diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index f4443b5fbf6e..e9a0f67c92ca 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2532,8 +2532,10 @@ static int add_hdmi_jack_kctl(struct hda_codec *codec, return err; spec->pcm_rec[pcm_idx].jack = jack; - jack->private_data = &spec->pcm_rec[pcm_idx]; - jack->private_free = free_hdmi_jack_priv; + if (IS_ENABLED(CONFIG_SND_JACK)) { + jack->private_data = &spec->pcm_rec[pcm_idx]; + jack->private_free = free_hdmi_jack_priv; + } return 0; }