sound/soc/amd/acp/acp70.c:217 acp70_pcm_resume() error: we previously assumed 'stream' could be null (see line 218)

From: Dan Carpenter
Date: Thu Dec 05 2024 - 08:35:04 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: feffde684ac29a3b7aec82d2df850fbdbdee55e4
commit: d3534684ada99ef8c0899eb28c62b4462483ee19 ASoC: amd: acp: add Kconfig options for acp7.0 based platform driver
config: x86_64-randconfig-161-20241205 (https://download.01.org/0day-ci/archive/20241205/202412052149.HYbkQDxc-lkp@xxxxxxxxx/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202412052149.HYbkQDxc-lkp@xxxxxxxxx/

smatch warnings:
sound/soc/amd/acp/acp70.c:217 acp70_pcm_resume() error: we previously assumed 'stream' could be null (see line 218)

vim +/stream +217 sound/soc/amd/acp/acp70.c

e84db124cb2158b Syed Saba Kareem 2023-10-21 208 static int __maybe_unused acp70_pcm_resume(struct device *dev)
e84db124cb2158b Syed Saba Kareem 2023-10-21 209 {
e84db124cb2158b Syed Saba Kareem 2023-10-21 210 struct acp_dev_data *adata = dev_get_drvdata(dev);
e84db124cb2158b Syed Saba Kareem 2023-10-21 211 struct acp_stream *stream;
e84db124cb2158b Syed Saba Kareem 2023-10-21 212 struct snd_pcm_substream *substream;
e84db124cb2158b Syed Saba Kareem 2023-10-21 213 snd_pcm_uframes_t buf_in_frames;
e84db124cb2158b Syed Saba Kareem 2023-10-21 214 u64 buf_size;
e84db124cb2158b Syed Saba Kareem 2023-10-21 215
e84db124cb2158b Syed Saba Kareem 2023-10-21 216 spin_lock(&adata->acp_lock);
e84db124cb2158b Syed Saba Kareem 2023-10-21 @217 list_for_each_entry(stream, &adata->stream_list, list) {
e84db124cb2158b Syed Saba Kareem 2023-10-21 @218 if (stream) {

The list iterator can't be NULL so this check isn't required.

e84db124cb2158b Syed Saba Kareem 2023-10-21 219 substream = stream->substream;
e84db124cb2158b Syed Saba Kareem 2023-10-21 220 if (substream && substream->runtime) {
e84db124cb2158b Syed Saba Kareem 2023-10-21 221 buf_in_frames = (substream->runtime->buffer_size);
e84db124cb2158b Syed Saba Kareem 2023-10-21 222 buf_size = frames_to_bytes(substream->runtime, buf_in_frames);
e84db124cb2158b Syed Saba Kareem 2023-10-21 223 config_pte_for_stream(adata, stream);
e84db124cb2158b Syed Saba Kareem 2023-10-21 224 config_acp_dma(adata, stream, buf_size);
e84db124cb2158b Syed Saba Kareem 2023-10-21 225 if (stream->dai_id)
e84db124cb2158b Syed Saba Kareem 2023-10-21 226 restore_acp_i2s_params(substream, adata, stream);
e84db124cb2158b Syed Saba Kareem 2023-10-21 227 else
e84db124cb2158b Syed Saba Kareem 2023-10-21 228 restore_acp_pdm_params(substream, adata);
e84db124cb2158b Syed Saba Kareem 2023-10-21 229 }
e84db124cb2158b Syed Saba Kareem 2023-10-21 230 }
e84db124cb2158b Syed Saba Kareem 2023-10-21 231 }
e84db124cb2158b Syed Saba Kareem 2023-10-21 232 spin_unlock(&adata->acp_lock);
e84db124cb2158b Syed Saba Kareem 2023-10-21 233 return 0;
e84db124cb2158b Syed Saba Kareem 2023-10-21 234 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki