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 4DC6EEEB56C for ; Fri, 8 Sep 2023 19:35:52 +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 E8244A4C; Fri, 8 Sep 2023 21:34:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E8244A4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694201750; bh=LsNGYyxSOf55GU0VS8hQG7NBZCorbOMYgTI/lqWeqOo=; 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=Ve3S2MbRRy7mP7TKIH3WSgdWapih1/5U2MIGD7T8WfliahNjJvPCMeWVQI+p7WE0b O2AE9NJ4KCPRr4xdBOug+DGilBqZI8fIKTQYd83nWZpOgdSqzJAE33+GKNrmgEZGJ4 56f05Y2ESjEbPAAqZMJh6DAMjkmqUc/leAwEFp2I= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 88E22F8055B; Fri, 8 Sep 2023 21:34:59 +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 C37A5F80431; Fri, 8 Sep 2023 21:34:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7C876F804F3; Fri, 8 Sep 2023 21:34:55 +0200 (CEST) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AD3EAF800F5; Fri, 8 Sep 2023 21:34:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AD3EAF800F5 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=r0jyKb2y 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 sin.source.kernel.org (Postfix) with ESMTPS id 521F3CE1C55; Fri, 8 Sep 2023 19:34:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81D38C433BF; Fri, 8 Sep 2023 19:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694201688; bh=LsNGYyxSOf55GU0VS8hQG7NBZCorbOMYgTI/lqWeqOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r0jyKb2yKOw1ugHzYs6HvM+5CLotFNX03xXhAXHO0hN0os3JkPudtwmLO6xxvAix3 7RGcOD/t2owWVTy7kFU8S6gq1QfadJ+v7wdcEb5cbwXl3Pg+NJrMlU2iy5sh0uUJ01 nGnj49859Zo89TkCcY37dali5iOiGfmmufNkjkdp1VRGfe+8VDUrXfhLwA8/b2dVOH df2dIdZVG93EIEVbBaBGIH/InV4A66Tud9QhYozV6W5Ok1iwjM/6VJloLLSNGvAASJ bEOf5w9Fy5dj8gMx1vzUMttJ3K7QZj1yzrwnk3dEvFYTLDxWVg/gx0IwfYd7z2Gauf 7nbpE3U4agFhw== 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.1 11/22] ASoC: SOF: topology: simplify code to prevent static analysis warnings Date: Fri, 8 Sep 2023 15:33:55 -0400 Message-Id: <20230908193407.3463368-11-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230908193407.3463368-1-sashal@kernel.org> References: <20230908193407.3463368-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.1.52 Content-Transfer-Encoding: 8bit Message-ID-Hash: B7D7WDVLHV6T7YVMO2BBPH6SGZDNG3KN X-Message-ID-Hash: B7D7WDVLHV6T7YVMO2BBPH6SGZDNG3KN 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 872e44408298f..e7305ce57ea1f 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1086,16 +1086,17 @@ 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; - if (!w->sname) + if (!sname) return; 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; switch (w->id) { -- 2.40.1