public inbox for [email protected]
 help / color / mirror / Atom feed
* [ammarfaizi2-block:broonie/sound/for-5.18 33/171] sound/soc/sof/compress.c:54 snd_sof_compr_fragment_elapsed() warn: variable dereferenced before check 'cstream' (see line 48)
@ 2022-03-11 18:59 Dan Carpenter
  2022-03-11 22:41 ` Ammar Faizi
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-03-11 18:59 UTC (permalink / raw)
  To: kbuild, Daniel Baluta
  Cc: lkp, kbuild-all, GNU/Weeb Mailing List, linux-kernel, Mark Brown

tree:   https://github.com/ammarfaizi2/linux-block broonie/sound/for-5.18
head:   6b6bb5e26222021abe1c5360f43b4c2ff1dd012f
commit: 6324cf901e14c6662be508f30485e0f09c54694d [33/171] ASoC: SOF: compr: Add compress ops implementation
config: microblaze-randconfig-m031-20220310 (https://download.01.org/0day-ci/archive/20220312/[email protected]/config)
compiler: microblaze-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

New smatch warnings:
sound/soc/sof/compress.c:54 snd_sof_compr_fragment_elapsed() warn: variable dereferenced before check 'cstream' (see line 48)

vim +/cstream +54 sound/soc/sof/compress.c

858f7a5c45cacb Daniel Baluta 2021-10-04  46  void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream)
858f7a5c45cacb Daniel Baluta 2021-10-04  47  {
6324cf901e14c6 Daniel Baluta 2022-01-20 @48  	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
                                                                                  ^^^^^^^^^^^^^^^^^^^^^^
6324cf901e14c6 Daniel Baluta 2022-01-20  49  	struct snd_compr_runtime *crtd = cstream->runtime;
                                                                                 ^^^^^^^^^^^^^^^^^
Dereference

858f7a5c45cacb Daniel Baluta 2021-10-04  50  	struct snd_soc_component *component;
6324cf901e14c6 Daniel Baluta 2022-01-20  51  	struct snd_compr_tstamp *tstamp;
858f7a5c45cacb Daniel Baluta 2021-10-04  52  	struct snd_sof_pcm *spcm;
858f7a5c45cacb Daniel Baluta 2021-10-04  53  
858f7a5c45cacb Daniel Baluta 2021-10-04 @54  	if (!cstream)
                                                    ^^^^^^^^
Checked too late

858f7a5c45cacb Daniel Baluta 2021-10-04  55  		return;
858f7a5c45cacb Daniel Baluta 2021-10-04  56  
6324cf901e14c6 Daniel Baluta 2022-01-20  57  	tstamp = crtd->private_data;
858f7a5c45cacb Daniel Baluta 2021-10-04  58  	component = snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
858f7a5c45cacb Daniel Baluta 2021-10-04  59  
858f7a5c45cacb Daniel Baluta 2021-10-04  60  	spcm = snd_sof_find_spcm_dai(component, rtd);
858f7a5c45cacb Daniel Baluta 2021-10-04  61  	if (!spcm) {
858f7a5c45cacb Daniel Baluta 2021-10-04  62  		dev_err(component->dev,
858f7a5c45cacb Daniel Baluta 2021-10-04  63  			"fragment elapsed called for unknown stream!\n");
858f7a5c45cacb Daniel Baluta 2021-10-04  64  		return;
858f7a5c45cacb Daniel Baluta 2021-10-04  65  	}
858f7a5c45cacb Daniel Baluta 2021-10-04  66  
6324cf901e14c6 Daniel Baluta 2022-01-20  67  	sof_set_transferred_bytes(tstamp, spcm->stream[cstream->direction].posn.host_posn,
6324cf901e14c6 Daniel Baluta 2022-01-20  68  				  crtd->buffer_size);
6324cf901e14c6 Daniel Baluta 2022-01-20  69  
858f7a5c45cacb Daniel Baluta 2021-10-04  70  	/* use the same workqueue-based solution as for PCM, cf. snd_sof_pcm_elapsed */
858f7a5c45cacb Daniel Baluta 2021-10-04  71  	schedule_work(&spcm->stream[cstream->direction].period_elapsed_work);
858f7a5c45cacb Daniel Baluta 2021-10-04  72  }

---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/[email protected]


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ammarfaizi2-block:broonie/sound/for-5.18 33/171] sound/soc/sof/compress.c:54 snd_sof_compr_fragment_elapsed() warn: variable dereferenced before check 'cstream' (see line 48)
  2022-03-11 18:59 [ammarfaizi2-block:broonie/sound/for-5.18 33/171] sound/soc/sof/compress.c:54 snd_sof_compr_fragment_elapsed() warn: variable dereferenced before check 'cstream' (see line 48) Dan Carpenter
@ 2022-03-11 22:41 ` Ammar Faizi
  0 siblings, 0 replies; 2+ messages in thread
From: Ammar Faizi @ 2022-03-11 22:41 UTC (permalink / raw)
  To: Dan Carpenter, kbuild, Daniel Baluta
  Cc: lkp, kbuild-all, GNU/Weeb Mailing List, linux-kernel, Mark Brown

On 3/12/22 1:59 AM, Dan Carpenter wrote:
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
> Reported-by: Dan Carpenter <[email protected]>
> 
> New smatch warnings:
> sound/soc/sof/compress.c:54 snd_sof_compr_fragment_elapsed() warn: variable dereferenced before check 'cstream' (see line 48)
> 
> vim +/cstream +54 sound/soc/sof/compress.c
> 
> 858f7a5c45cacb Daniel Baluta 2021-10-04  46  void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream)
> 858f7a5c45cacb Daniel Baluta 2021-10-04  47  {
> 6324cf901e14c6 Daniel Baluta 2022-01-20 @48  	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
>                                                                                    ^^^^^^^^^^^^^^^^^^^^^^
> 6324cf901e14c6 Daniel Baluta 2022-01-20  49  	struct snd_compr_runtime *crtd = cstream->runtime;
>                                                                                   ^^^^^^^^^^^^^^^^^
> Dereference
> 
> 858f7a5c45cacb Daniel Baluta 2021-10-04  50  	struct snd_soc_component *component;
> 6324cf901e14c6 Daniel Baluta 2022-01-20  51  	struct snd_compr_tstamp *tstamp;
> 858f7a5c45cacb Daniel Baluta 2021-10-04  52  	struct snd_sof_pcm *spcm;
> 858f7a5c45cacb Daniel Baluta 2021-10-04  53
> 858f7a5c45cacb Daniel Baluta 2021-10-04 @54  	if (!cstream)
>                                                      ^^^^^^^^
> Checked too late

Hi Dan,

Thanks for reporting, it has already been fixed in commit
    
   7e4bfcf10a03981 ("ASoC: SOF: compress: fix null check after dereference")

   Link: https://git.kernel.org/broonie/sound/c/7e4bfcf10a03981

Regards,
-- 
Ammar Faizi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-11 22:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-11 18:59 [ammarfaizi2-block:broonie/sound/for-5.18 33/171] sound/soc/sof/compress.c:54 snd_sof_compr_fragment_elapsed() warn: variable dereferenced before check 'cstream' (see line 48) Dan Carpenter
2022-03-11 22:41 ` Ammar Faizi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox