From mboxrd@z Thu Jan 1 00:00:00 1970 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 DC934EEB566 for ; Fri, 8 Sep 2023 19:31:32 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0D1FB886; Fri, 8 Sep 2023 21:30:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0D1FB886 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694201490; bh=X1xul51WPSgENpfUiZWxVpGuk1QC6m286XjGYj+ND2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=C9gj9pB0sJBZO9e8zwYY2ZPFr9U02aNu9Ts1TEhDwuzvo6dMIhpZx4ORep42SDP1v yQfs6UAp18K1bW3urFWE+sfV0OUDajk7R/5Jfs9Lpvdf/HFpjH4nROXcfGxE8Tsr+0 cmeWtEH6/L5QAfCoteHLGzrIcZuPHXIy8hX8NbF0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id AED08F8055B; Fri, 8 Sep 2023 21:30:39 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 428B0F80527; Fri, 8 Sep 2023 21:30:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4A37CF80527; Fri, 8 Sep 2023 21:30:36 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0219AF800F5; Fri, 8 Sep 2023 21:30:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0219AF800F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=SSWPkChz 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 Message-ID-Hash: MUFWO2EBMOS2MIRXJYFTYYO6LCELQDGW X-Message-ID-Hash: MUFWO2EBMOS2MIRXJYFTYYO6LCELQDGW X-MailFrom: sashal@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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