Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp612455pxb; Tue, 5 Apr 2022 15:57:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSE1EaPosw1HuKGLIUO+ixwFFXoHE0Lr+m0ySuhG6W7ns5hvblo1tgIuEfazz/FWWePiKV X-Received: by 2002:a65:6705:0:b0:399:322e:b7d2 with SMTP id u5-20020a656705000000b00399322eb7d2mr4764959pgf.49.1649199479190; Tue, 05 Apr 2022 15:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649199479; cv=none; d=google.com; s=arc-20160816; b=eDVrqkTQacNISecaWkOOTdkb4SgLm6ItICj/5dBeXCdhsllCG70y76lPW1s2fwnhsu MXM/lXtKT1dpnu7kMigo3dzrdC68rUCD/ccf51JryyFk0+qdqMc5Drfm1slrvY9wdzxK BciWdZNzSmJlYbhklP9B1DeF8fIJl7eoDNFVw4HDIF0z6MckJLBX2D5jSYoM4YHBHw2w fXPtttw9SU74MBZf6niwdBJExpVs8s3TYfAz4QRsBf9SQt69/riX3/i6Hri4Ss+5S4Yy V36gvCNFpinkIGwirg+NPn42nHWftJpjBqNHvdttc7EQXXQScrh7dkFc4OFUuohHL2tu y5nQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=y2M02PJrmCGfgfzHvZMuLyruiD8Bs2zPhsE510cAR3s=; b=E1dIyBeX3ny37mwW23OySkr+S5dGWM0DqcXN/7wzXhhWLLfqJx6bKhqFaUpBwx7oyr tR648Gv/JxJJfegbFG+br7+l7uNxk+wcnMleB31So7Atv0WEjz3Yb1k3Alrbanwyd2Dg A9Gzn7nUjT+XmbFRTWIkPBF8quk/7q3TJTesKF2UL5uJft6dHBdZSh3yJguY/Elm4aAC osVuwr3T9HGqvNOF7fc5jmdBeJCG9+twqkCH/yrnYDt+m+R/bl3MrSZ19syESDXLkBMI G0I3Q4/ecbG/ZA10gc+ULyGnOQzpU91yYLrpOXhTqXastmqnYzj9a+Q06yWXP7AY43Rh IE6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HAVTFq1+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q12-20020a170902bd8c00b001564f2a0782si12397125pls.345.2022.04.05.15.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 15:57:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HAVTFq1+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A1771667E2; Tue, 5 Apr 2022 15:39:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355276AbiDEOCb (ORCPT + 99 others); Tue, 5 Apr 2022 10:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234094AbiDEJae (ORCPT ); Tue, 5 Apr 2022 05:30:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A966E388C; Tue, 5 Apr 2022 02:17:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E66F2615E4; Tue, 5 Apr 2022 09:17:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 053B3C385A0; Tue, 5 Apr 2022 09:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150240; bh=2cT+2fN9BWDAbDMBdt2nyr/WEUKFueq/21+yNuMyO5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HAVTFq1+lq0LC0cyjqypNLXoNFR1MGfxa6RcLHTC/ZAf+XMIU3ZK5p94zoJd9c0CO 0HtrUKz7MfYmWUzDhmrd6uvLKW8MUxCagjfxHPT+plBc6sirhXAijKnoU8frqTXwON TRFTC70x6n1kxM05/2cYgwF3n+RtLeqk+OF3s8W0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Dan Carpenter , Jiasheng Jiang , Charles Keepax , Mark Brown Subject: [PATCH 5.16 0966/1017] ASoC: soc-compress: Change the check for codec_dai Date: Tue, 5 Apr 2022 09:31:19 +0200 Message-Id: <20220405070422.880179514@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Jiasheng Jiang commit ccb4214f7f2a8b75acf493f31128e464ee1a3536 upstream. 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 Reviewed-by: Charles Keepax Link: https://lore.kernel.org/r/20220310030041.1556323-1-jiasheng@iscas.ac.cn Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/soc-compress.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -567,16 +567,19 @@ int snd_soc_new_compress(struct snd_soc_ 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)