From patchwork Thu Apr 2 11:21:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 6147091 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 38C119F389 for ; Thu, 2 Apr 2015 11:22:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C4EC20396 for ; Thu, 2 Apr 2015 11:22:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4D82B2038C for ; Thu, 2 Apr 2015 11:22:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7B1D82604FD; Thu, 2 Apr 2015 13:22:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 0608D2604CA; Thu, 2 Apr 2015 13:22:06 +0200 (CEST) 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 BCEA42604C3; Thu, 2 Apr 2015 13:22:03 +0200 (CEST) Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by alsa0.perex.cz (Postfix) with ESMTP id 374352604C3 for ; Thu, 2 Apr 2015 13:21:56 +0200 (CEST) Received: by pddn5 with SMTP id n5so86698291pdd.2 for ; Thu, 02 Apr 2015 04:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=xAmbeENSXNTifKiAgSPJvnzjgAsTeOuCLejd38roIjU=; b=rY0jYfTUH/BmL6dKSopKoiopN3rSzNqxEv9KD9WKEPWNT4FpagHrNXDRulTKHx8BzG H9npDpmMOxGBWkBs+wuZxRVVR5gnXUXGFVUyL33jwNs7v70vbETWwZrgwkpZtnStzIJo MC3iX50UJ2SEuC3CzAxNv+FepMpRxEKOtccoIxwm1nbcR12qH5bUii0tsER61L8Qi+sV Jf8K27utRb+vIDHlDk5lFnNaJtQY77Bm9OZnRUxoZEDYaMja//TI1X9Q+sB3TrLyE87i Yn8Z7x9mFB3M3cd6ul0jixwKobJMLnLZh5macvRsGoTzb9VB3F27yYVVdm6ILVMHa16q EjQw== X-Received: by 10.66.65.203 with SMTP id z11mr44354714pas.95.1427973712755; Thu, 02 Apr 2015 04:21:52 -0700 (PDT) Received: from localhost.localdomain ([122.169.169.196]) by mx.google.com with ESMTPSA id hb6sm4907182pbd.88.2015.04.02.04.21.50 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Apr 2015 04:21:52 -0700 (PDT) From: Sudip Mukherjee To: Jaroslav Kysela , Takashi Iwai Date: Thu, 2 Apr 2015 16:51:43 +0530 Message-Id: <1427973703-2365-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.8.1.2 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [alsa-devel] [PATCH] ALSA: hda: fix possible null dereference 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 we are dereferencing pcm first then checking pcm. instead now lets put them in same if condition so that pcm is checked first. Signed-off-by: Sudip Mukherjee --- sound/pci/hda/hda_codec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 145cae7..7df18e2 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3717,9 +3717,8 @@ static int add_std_chmaps(struct hda_codec *codec) struct snd_pcm_chmap *chmap; const struct snd_pcm_chmap_elem *elem; - if (pcm->own_chmap) - continue; - if (!pcm || !hinfo->substreams) + if (!pcm || pcm->own_chmap || + !hinfo->substreams) continue; elem = hinfo->chmap ? hinfo->chmap : snd_pcm_std_chmaps; err = snd_pcm_add_chmap_ctls(pcm->pcm, str, elem,