Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1003224pxb; Wed, 6 Apr 2022 06:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfKpkt01q1zuP+kdIcr5Haxzbruie4Q3exSerFCuXs37Y9HOZDS61aWma5Qn/6xXvke9mx X-Received: by 2002:a05:6a00:248d:b0:4fd:e026:f4c8 with SMTP id c13-20020a056a00248d00b004fde026f4c8mr9011267pfv.21.1649251778610; Wed, 06 Apr 2022 06:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649251778; cv=none; d=google.com; s=arc-20160816; b=yG6mzvoHGrrAyI6CEZi8h2dsH2ANuxaxd3eMsFte10xh8IuzF6vJx7nAunFWiOuo5y lshca8kFg48KBCRL4QXbJIeLPcPzttqWfyHbHBXoWDlO2iE/0mK0npwURBcCuz/w9go4 7j73KqzLDYOzTjBHJTJ24dUsqNnHdCI9Vz12H9TxdvzyvWVRGHbYnoCgSs97/Mbci7IB Vwg/Vb65CUiM2EyPJYHGYMlPUODrQjyd7gwA0iNX1d7py0Mo5FlMxLhgo+m9sb9KTID3 DjBmf1FJW9EsT+2tULHZtoCjpZ9nVkFrmHx/J2hay1nWbLVK4CE1S+i5KkNbkzhGioax 0p5w== 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=8FNviKKTcQvnebwma+HAzb3F9qZGGSF0Djzez77CkrU=; b=vEAMWA5ERB1Ska/K7fQOXoR71gNwmGztWuay8JBY4rISmy1MTkPVNAlCq9QcOXVmKM jNFycB5faKmiGoLEpNGsO4g8RlqJZ8eKGbjOadtZG91QCOosFJY2q2U0INDR+JFEteM6 2xMQv+g2CbgfUqh42GfGYDiekNNWe9DfW8maVFv/ey54il6qKRhR4aNl8jdQTGaeaCg+ M0GuCd5xiVMZ+2kceHQrWAug/oYmiC8uQCVLWePLCJXmlw/hlwUjfFwlwWvawmKEct35 CtZf5XeCUWoUfPfksgj7IoNs0Sn6GrpGMURJ8jpF4hXsEyZAPoWYB7JzL5aGgB8awRUG OmFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rv4J1Sl8; 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 37-20020a630c65000000b0038203e0be84si15783827pgm.605.2022.04.06.06.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:29:38 -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=Rv4J1Sl8; 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 9D798411F0F; Wed, 6 Apr 2022 04:07:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1588062AbiDFALN (ORCPT + 99 others); Tue, 5 Apr 2022 20:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354394AbiDEKOA (ORCPT ); Tue, 5 Apr 2022 06:14:00 -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 9CAED692B9; Tue, 5 Apr 2022 02:59:55 -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 3B6E961747; Tue, 5 Apr 2022 09:59:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D4B5C385A1; Tue, 5 Apr 2022 09:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152794; bh=KkXa4M8bh9HoZxGTFoJrJ0d5+mzS+p1f1Yj8rGGIdko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rv4J1Sl8/KxMQqzTgq4l9NS2/Q+bGupBJiL5vy0DfFHpjcziAjMZNXsJ8xmJmfptK KvmbEO//dpX+BmhnwiIAmyeisO7hTscxJi2/NqUq0Bf4AHbr8ZNECaWdzcmZe8D56l gXUUHEjPPTbNrg+QE0yGslI2atSWCqUXTjLf24hU= 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.15 868/913] ASoC: soc-compress: Change the check for codec_dai Date: Tue, 5 Apr 2022 09:32:10 +0200 Message-Id: <20220405070405.841824016@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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 @@ -534,16 +534,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)