Skip to contentSkip to conversation

sound/soc/soc-card.c:215 snd_soc_card_set_bias_level() error: we previously assumed 'card' could be null (see line 212)

PATCH New Dan Carpenter 1 participant 1 message Oct 3, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 62/71 sound/soc/soc-card.c:215 snd_soc_card_set_bias_level() error: we previously assumed 'card' could be null (see line 212)

tree:   https://github.com/morimoto/linux sound-error-cleanup-2024-09-30
head:   b31c07e66a585a36ee2d6795e3dbbb4cbabab338
commit: d6485ea092fa6dd4f36bfbb4c2eecef748734bf1 [62/71] ASoC: add common snd_soc_ret() and use it
config: x86_64-randconfig-161-20241003 (https://download.01.org/0day-ci/archive/20241003/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
sound/soc/soc-card.c:215 snd_soc_card_set_bias_level() error: we previously assumed 'card' could be null (see line 212) sound/soc/soc-card.c:227 snd_soc_card_set_bias_level_post() error: we previously assumed 'card' could be null (see line 224)

vim +/card +215 sound/soc/soc-card.c

39caefda0a30ca Kuninori Morimoto 2020-05-28  206  int snd_soc_card_set_bias_level(struct snd_soc_card *card,
39caefda0a30ca Kuninori Morimoto 2020-05-28  207  				struct snd_soc_dapm_context *dapm,
39caefda0a30ca Kuninori Morimoto 2020-05-28  208  				enum snd_soc_bias_level level)
39caefda0a30ca Kuninori Morimoto 2020-05-28  209  {
39caefda0a30ca Kuninori Morimoto 2020-05-28  210  	int ret = 0;
39caefda0a30ca Kuninori Morimoto 2020-05-28  211  
39caefda0a30ca Kuninori Morimoto 2020-05-28 @212  	if (card && card->set_bias_level)
                                                            ^^^^

Delete this check

39caefda0a30ca Kuninori Morimoto 2020-05-28 213 ret = card->set_bias_level(card, dapm, level);
39caefda0a30ca Kuninori Morimoto 2020-05-28 214

39caefda0a30ca Kuninori Morimoto 2020-05-28 @215  	return soc_card_ret(card, ret);
                                                                            ^^^^

If card is NULL then this will crash

39caefda0a30ca Kuninori Morimoto 2020-05-28  216  }
d41278ea0579a8 Kuninori Morimoto 2020-05-28  217  
d41278ea0579a8 Kuninori Morimoto 2020-05-28  218  int snd_soc_card_set_bias_level_post(struct snd_soc_card *card,
d41278ea0579a8 Kuninori Morimoto 2020-05-28  219  				     struct snd_soc_dapm_context *dapm,
d41278ea0579a8 Kuninori Morimoto 2020-05-28  220  				     enum snd_soc_bias_level level)
d41278ea0579a8 Kuninori Morimoto 2020-05-28  221  {
d41278ea0579a8 Kuninori Morimoto 2020-05-28  222  	int ret = 0;
d41278ea0579a8 Kuninori Morimoto 2020-05-28  223  

d41278ea0579a8 Kuninori Morimoto 2020-05-28 @224 if (card && card->set_bias_level_post)
d41278ea0579a8 Kuninori Morimoto 2020-05-28 225 ret = card->set_bias_level_post(card, dapm, level);
d41278ea0579a8 Kuninori Morimoto 2020-05-28 226
d41278ea0579a8 Kuninori Morimoto 2020-05-28 @227 return soc_card_ret(card, ret);
d41278ea0579a8 Kuninori Morimoto 2020-05-28 228 }

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