Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: SOF: topology: simplify code to prevent static analysis warnings

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@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Yaochun Hung <yc.hung@mediatek.com>
Link: https://lore.kernel.org/r/20230731213748.440285-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Pierre-Louis Bossart and committed by
Mark Brown
55cb3dc2 e44222c2

+3 -2
+3 -2
sound/soc/sof/topology.c
··· 1117 1117 { 1118 1118 struct snd_soc_card *card = scomp->card; 1119 1119 struct snd_soc_pcm_runtime *rtd; 1120 + const char *sname = w->sname; 1120 1121 struct snd_soc_dai *cpu_dai; 1121 1122 int i, stream; 1122 1123 1123 - if (!w->sname) 1124 + if (!sname) 1124 1125 return; 1125 1126 1126 1127 if (w->id == snd_soc_dapm_dai_out) ··· 1134 1133 list_for_each_entry(rtd, &card->rtd_list, list) { 1135 1134 /* does stream match DAI link ? */ 1136 1135 if (!rtd->dai_link->stream_name || 1137 - strcmp(w->sname, rtd->dai_link->stream_name)) 1136 + strcmp(sname, rtd->dai_link->stream_name)) 1138 1137 continue; 1139 1138 1140 1139 for_each_rtd_cpu_dais(rtd, i, cpu_dai)