[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230908193407.3463368-11-sashal@kernel.org>
Date: Fri, 8 Sep 2023 15:33:55 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
Rander Wang <rander.wang@...el.com>,
Daniel Baluta <daniel.baluta@....com>,
Yaochun Hung <yc.hung@...iatek.com>,
Mark Brown <broonie@...nel.org>,
Sasha Levin <sashal@...nel.org>, lgirdwood@...il.com,
peter.ujfalusi@...ux.intel.com, yung-chuan.liao@...ux.intel.com,
ranjani.sridharan@...ux.intel.com, perex@...ex.cz, tiwai@...e.com,
matthias.bgg@...il.com, sound-open-firmware@...a-project.org,
alsa-devel@...a-project.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: [PATCH AUTOSEL 6.1 11/22] ASoC: SOF: topology: simplify code to prevent static analysis warnings
From: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
[ 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 <pierre-louis.bossart@...ux.intel.com>
Reviewed-by: Rander Wang <rander.wang@...el.com>
Reviewed-by: Daniel Baluta <daniel.baluta@....com>
Reviewed-by: Yaochun Hung <yc.hung@...iatek.com>
Link: https://lore.kernel.org/r/20230731213748.440285-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@...nel.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
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
Powered by blists - more mailing lists