Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A670EEB566 for ; Fri, 8 Sep 2023 19:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RYbq/1uKqBsRvTXd6Ar+lYUAO3ftf14oUwtqjan/UBQ=; b=uUpBWFW9q6734vdLiysUTyFL3T e0DZeSSsQhzxPWrJ5YADP3RwfzQeBz+vveiKXRES9mPopaZ+X4m0FM1LK0gCwTgR+E2MLaA1CsRh+ JVAGY0Sv6I+yn11zHKVAJLFV6PJI5w8nwx0lNtXG/hxOmwy6qLaRTouAL0tk4bYCjRD42pY5Oftaw +a4TX8VIKo6WLoJfKra6qyJ4PHno2lFJSmRjtNumN6Z2zUkbwKdF9yuiviDl6Kg4WrEpVCW/xUh95 xwHULUYiSrj1V+nCB/kAIzZ/AlUKNWp/V6Riagz9O5GHuVZ5rhYRHv5F7wzaAYHKB1FB9WknAqvXO FzPJzGhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qehBa-00EM3O-22; Fri, 08 Sep 2023 19:30:34 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qehBW-00EM1v-2J; Fri, 08 Sep 2023 19:30:32 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 311D9B821DA; Fri, 8 Sep 2023 19:30:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4A53C43391; Fri, 8 Sep 2023 19:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694201427; bh=X1xul51WPSgENpfUiZWxVpGuk1QC6m286XjGYj+ND2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SSWPkChzQZxPeKZAcyJ8GzM0CGMNHcQHgt/VqYNILRhnOSiVhws/ui8CHYMPqk1d/ vI00kuX+EGiqkm0QXZriQPXLU7sMwRpVQjYd7pSWY1bA/Rmv9Nk/kH+VFVlMawIKsz tqIIHM9GKZgYjEFpzXBujQyuL3TIp2HX4jd8kAhwV8AUDc9F2pyT3G1kh4kfU049O8 zDTEwLlto8GZJJ24i74PzB8RBxWDPJKuO+0R6o/xoogezHz7Mnn6TFyUz+CQ1t9RaX j7fPQGlAfCMk0ZnAc+Qo2OpmQOzvu9jG5zS3cmOBSUOxCPz3F/UvLbmrdH813QRJCe vbm6sUjHtQ5eQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pierre-Louis Bossart , Rander Wang , Daniel Baluta , Yaochun Hung , Mark Brown , Sasha Levin , lgirdwood@gmail.com, peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com, ranjani.sridharan@linux.intel.com, perex@perex.cz, tiwai@suse.com, matthias.bgg@gmail.com, sound-open-firmware@alsa-project.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 6.5 17/36] ASoC: SOF: topology: simplify code to prevent static analysis warnings Date: Fri, 8 Sep 2023 15:28:28 -0400 Message-Id: <20230908192848.3462476-17-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230908192848.3462476-1-sashal@kernel.org> References: <20230908192848.3462476-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.2 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230908_123031_045134_57038177 X-CRM114-Status: GOOD ( 12.59 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Pierre-Louis Bossart [ Upstream commit 55cb3dc271d81f1982c949a2ac483a6daf613b92 ] make KCFLAGS='-fanalyzer' sound/soc/sof/intel/ reports a possible NULL pointer dereference. sound/soc/sof/topology.c:1136:21: error: dereference of NULL ‘w’ [CWE-476] [-Werror=analyzer-null-dereference] 1136 | strcmp(w->sname, rtd->dai_link->stream_name)) The code is rather confusing and can be simplified to make static analysis happy. No functionality change. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Daniel Baluta Reviewed-by: Yaochun Hung Link: https://lore.kernel.org/r/20230731213748.440285-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/topology.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 698129dccc7df..3866dd3cba695 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1117,10 +1117,11 @@ static void sof_disconnect_dai_widget(struct snd_soc_component *scomp, { struct snd_soc_card *card = scomp->card; struct snd_soc_pcm_runtime *rtd; + const char *sname = w->sname; struct snd_soc_dai *cpu_dai; int i, stream; - if (!w->sname) + if (!sname) return; if (w->id == snd_soc_dapm_dai_out) @@ -1133,7 +1134,7 @@ static void sof_disconnect_dai_widget(struct snd_soc_component *scomp, list_for_each_entry(rtd, &card->rtd_list, list) { /* does stream match DAI link ? */ if (!rtd->dai_link->stream_name || - strcmp(w->sname, rtd->dai_link->stream_name)) + strcmp(sname, rtd->dai_link->stream_name)) continue; for_each_rtd_cpu_dais(rtd, i, cpu_dai) -- 2.40.1