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 B535DEEB566 for ; Fri, 8 Sep 2023 19:34:56 +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=w0ISs/aVbKsryb4JD09PL7Eg3X3J5aNq78lz4xsNFVU=; b=1I5wBh8xbgCnOnYHzHuzHxDoTe 5lnx+LlPJqyift7lMDbGriChDqb4+Z/Xpe3ERmyjzqplxoo9sEn4f0q5Zvy/03GGKl7LHiMn7r/me HdT4/w8tGnUZNBrl4ltuGU1OrT9q9pBX3WoFE8W+D+CWB/bjtN6e+1YmWEZBOcMWLZNhfH1s6Lkvr DJMDGW7NLCV11VnaA1MGrYqETjgOM0US2EFWJH28zGb6tBs3Ks3OBF2L0R5c36CqYctEe69ZxtYYe gFc+E4jNnBJK6s7MXQaiDcEqu1TN4Wlr5+/Rq29T0xg1XozISocPJqmPJOQMRFcHylhoGOLA2ricP uifcWnlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qehFn-00ENLM-1u; Fri, 08 Sep 2023 19:34:55 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qehFk-00ENIZ-0T; Fri, 08 Sep 2023 19:34:53 +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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230908_123452_362030_3675BA6A X-CRM114-Status: GOOD ( 12.48 ) 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 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