Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1481448pxp; Thu, 10 Mar 2022 06:20:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOwJJ8gsoHStQuu2yU9Mud85iAKWjcKo7A5xQLrSPQzNQYS2EIqKdK35FwFyxvNsJbvrYT X-Received: by 2002:a17:902:7b8d:b0:14f:f1c2:9ff4 with SMTP id w13-20020a1709027b8d00b0014ff1c29ff4mr5143563pll.54.1646922037438; Thu, 10 Mar 2022 06:20:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646922037; cv=none; d=google.com; s=arc-20160816; b=cW2kcLhDe1aYavqvzg1D8+v2rUUSFzTWqDNdwjg3C/awbSoYByvpBEnzobzpyKFNnT t5RXL+K6Wwi6Uibv8/grrgtP0LYTxtsQBWtjgPtGJPcw2vi9keDjLKGLXd28UvXv6VHx 9D1g72x+la1T1TybpSvaFMqyoURd2dIkselrde/UaMmZhGfkxQtdB1k0U6wzeRO+I0l2 T7DUADlB54k61x/BDirjqOHATzkFaZbjBzle3BJBhX6/EU9k8uTzZbzXDueJmUzgu8XS TPzzvwPsO+nsjsVjk9kXMg2/aNWqWGq2YEBvYzOmRH0LSls6+7Z5TYLv6HHOyXbUH15x L4VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=rkQMF4tsU0nMncjQRGhWgNk7SFZ4V3RXG/mep0tOz1Y=; b=HoRS+8txfewOQSXBlrW8i6Q+EJvfacYSyzU3+SN+sfePd2DpIFlnt0tOViFFMmHrHP 7jWjIPnNXIJMcHvel/Gxb2ZqERhclP2+7pU2KDizE5628XQ0lxUIOCbMx99a98Vvg4xc oQmnoJzggrQMI2c2HDrCI6rFleoL8g2ZLJGByF2+waCN9uhcECSvSJ1JHuwUbIVPps/1 qIhdZfqEs2PzOx8ni80UJe1p7DBbZWyBjCRYwrtcOLY02dMaaUxSLu/2vCUKevzo9NnL +CMJ3/6BtA8HReht5it63h+vcn/mRkKhh7gn3lrrGqBnvmBTgrhTGx78ofMi3q9RDZSv hKfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a635943000000b003739a5a5451si4863982pgm.260.2022.03.10.06.20.18; Thu, 10 Mar 2022 06:20:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238870AbiCJDCV (ORCPT + 99 others); Wed, 9 Mar 2022 22:02:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234539AbiCJDCU (ORCPT ); Wed, 9 Mar 2022 22:02:20 -0500 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 470201255B9 for ; Wed, 9 Mar 2022 19:01:18 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-05 (Coremail) with SMTP id zQCowAC3vdnaaSliK8S8Ag--.21223S2; Thu, 10 Mar 2022 11:00:43 +0800 (CST) From: Jiasheng Jiang To: dan.carpenter@oracle.com, vkoul@kernel.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jiasheng Jiang , kernel test robot Subject: [PATCH] ASoC: soc-compress: Change the check for codec_dai Date: Thu, 10 Mar 2022 11:00:41 +0800 Message-Id: <20220310030041.1556323-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowAC3vdnaaSliK8S8Ag--.21223S2 X-Coremail-Antispam: 1UD129KBjvJXoW7tr1rZr4UJFWkuw4xGw15Jwb_yoW8AFW7pr 4xurW2qFyrtFyIvw4rAw4S93WfGryxua1F9FnIv34xAr45XFs8Ww1Utw4vyFW8C3yDtr1D Z39FyayfWFn8CFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvF14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr 1j6rxdM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E 8cxan2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I 8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8 ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x 0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AK xVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvj fUoOJ5UUUUU X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It should be better to reverse the check on codec_dai and returned early in order to be easier to understand. Fixes: de2c6f98817f ("ASoC: soc-compress: prevent the potentially use of null pointer") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Jiasheng Jiang --- sound/soc/soc-compress.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index f4b376a71be8..e9dd25894dc0 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -567,16 +567,19 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) return -EINVAL; } - /* check client and interface hw capabilities */ - if (codec_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; + if (!codec_dai) { + dev_err(rtd->card->dev, "Missing codec\n"); + return -EINVAL; } + /* 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; + /* * Compress devices are unidirectional so only one of the directions * should be set, check for that (xor) -- 2.25.1