Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3261961pxb; Wed, 13 Oct 2021 02:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMH3tET8Y4iSIyRsU7kBuRE2TRkbpz/5/DhStmNqf2Piu2mrLstKPocW4NrFi/LQVWlhim X-Received: by 2002:a17:90a:4207:: with SMTP id o7mr11983551pjg.61.1634116844225; Wed, 13 Oct 2021 02:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634116844; cv=none; d=google.com; s=arc-20160816; b=balxKa4h+Qk2c47MFUw6caPlDXuy3PiOe+FzNdXPXX0Qao6eHDeFHY256DW79ChDdF OGaoN72naoRfiBwI6dUz6+JJQyWWDVYvP6VqKalYg24gt4sQvENexBJcal10grOSlsym H/peUuFUMS8P1+LOmKng2UlXboq8pcuDdE4Q/zfQf3mc74Qajz2Q6+lUQI8yBZ0fnYZY zrmUfHHYbp9uwAozwGQ90ptbrNxYyr8/e/ShOi3c26qalYMmIbwgZEeviz5ds9VOVDCp VdRMjVCtltXMH62L9MEjAQMzF+e0hpiio4RxmbAUN88mED6L4dUFoWXy94QyMdtD806K D+aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=Ij1uyLTdLsD4T2BuoNO41OicpHkbhcXIVQALfBrlw84=; b=iuQyy6C8uYzRtY5yok61ViOgLynilI3emtJxNKxbUDPQ9+IXHK11iYAMaw/tujK0r1 I+L8sjzad0MFdtm3+Ac+C7hVGS00GCgmZ2LkNBhE2oX+r1jry11ZPW9iBe+qRJ5N7hf0 XgiD3KKkViEqXt4lAz8UokBq1wwe+EhDojv1SWFJ4cjye/YaQ/0tvInAw/2AmUPiAz7B r0fUZaY8Ov8/2+2I9Rw3JQBinm/OFgSlpmcpRF0DFkedSdXk3xz+CxcJPkmsQQrB10sk zOg3zAg39J5Jm/JvCgLz4gswhzyDG5l5tkRpr5elcpElJI4Zb/2eJm7KrYzb12Qmqa/q 43WQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u11si14013802plf.425.2021.10.13.02.20.30; Wed, 13 Oct 2021 02:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239072AbhJMJUT (ORCPT + 99 others); Wed, 13 Oct 2021 05:20:19 -0400 Received: from smtp23.cstnet.cn ([159.226.251.23]:44350 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238900AbhJMJUS (ORCPT ); Wed, 13 Oct 2021 05:20:18 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-03 (Coremail) with SMTP id rQCowABnb6s6pGZhPDBrAw--.20277S2; Wed, 13 Oct 2021 17:17:46 +0800 (CST) From: Jiasheng Jiang To: vkoul@kernel.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] ASoC: soc-compress: prevent the potentially use of null pointer Date: Wed, 13 Oct 2021 09:17:44 +0000 Message-Id: <1634116664-1784856-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: rQCowABnb6s6pGZhPDBrAw--.20277S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uw13KFyDur17JF43XFy8Grg_yoW8WF18pw s7uFWIqFWrtFyIvw1rJw4F9F1fGFyxua1F9F1ag348Ar45Xanxur1UJr4kAFy8GrWjqr1v v3sFy3y3XF15CrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkm14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK67AK6r4f MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV W8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUeLvtDUUUU X-Originating-IP: [124.16.138.128] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The codec_dai and the cpu_dai are from rtd. When the rtd->dais[0] or rtd->dais[rtd->num_cpus] is None, it could lead to the use of null pointer in the snd_soc_dai_stream_valid(). So it might be better to add the check before the use of snd_soc_dai_stream_valid(). Fixes: 467fece ("ASoC: soc-dai: move snd_soc_dai_stream_valid() to soc-dai.c") Signed-off-by: Jiasheng Jiang --- sound/soc/soc-compress.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index b4f5935..67c3df1 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -535,12 +535,14 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) } /* check client and interface hw capabilities */ - if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && - snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK)) - playback = 1; - if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && - snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE)) - capture = 1; + if (codec_dai && cpu_dai) { + if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && + snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK)) + playback = 1; + if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && + snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE)) + capture = 1; + } /* * Compress devices are unidirectional so only one of the directions -- 2.7.4