Skip to contentSkip to conversation

sound/usb/pcm.c:1053 snd_usb_pcm_prepare() warn: variable dereferenced before check 'subs->cur_audiofmt' (see line 1049)

PATCH New Dan Carpenter 1 participant 1 message Oct 20

lore
Share & tools
lore
#0 lore raw

PATCH 291/291 sound/usb/pcm.c:1053 snd_usb_pcm_prepare() warn: variable dereferenced before check 'subs->cur_audiofmt' (see line 1049)

tree:   https://android.googlesource.com/kernel/common android12-kiwi-5.10
head:   aaa0cf06ed53d6805dfa9099535f6fc052c49086
commit: 1eb185541df90c3f790676b9ac362683de3519f2 [291/291] ANDROID: sound: usb: Add vendor's hooking interface
config: i386-randconfig-2200-20261020 (https://download.01.org/0day-ci/archive/20261020/[email protected]/config)
compiler: gcc-12 (Debian 12.4.0-5) 12.4.0
smatch: v0.5.0-9187-g5189e3fb

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/usb/pcm.c:1053 snd_usb_pcm_prepare() warn: variable dereferenced before check 'subs->cur_audiofmt' (see line 1049)

vim +1053 sound/usb/pcm.c

e5779998bf8b70e Daniel Mack          2010-03-04  1041  static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
e5779998bf8b70e Daniel Mack          2010-03-04  1042  {
e5779998bf8b70e Daniel Mack          2010-03-04  1043  	struct snd_pcm_runtime *runtime = substream->runtime;
e5779998bf8b70e Daniel Mack          2010-03-04  1044  	struct snd_usb_substream *subs = runtime->private_data;
61a709504b07911 Dylan Reid           2012-09-18  1045  	struct usb_host_interface *alts;
61a709504b07911 Dylan Reid           2012-09-18  1046  	struct usb_interface *iface;
61a709504b07911 Dylan Reid           2012-09-18  1047  	int ret;
e5779998bf8b70e Daniel Mack          2010-03-04  1048  
1eb185541df90c3 JaeHun Jung          2020-05-26 @1049  	ret = snd_vendor_set_pcm_buf(subs->dev, subs->cur_audiofmt->iface);
                                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^

Android adds this vender hook

1eb185541df90c3 JaeHun Jung          2020-05-26  1050  	if (ret)
1eb185541df90c3 JaeHun Jung          2020-05-26  1051  		return ret;
1eb185541df90c3 JaeHun Jung          2020-05-26  1052  
e5779998bf8b70e Daniel Mack          2010-03-04 @1053  	if (! subs->cur_audiofmt) {
                                                              ^^^^^^^^^^^^^^^^^^

before the NULL check

0ba41d917eeb87f Takashi Iwai         2014-02-26  1054  		dev_err(&subs->dev->dev, "no format is specified!\n");
e5779998bf8b70e Daniel Mack          2010-03-04  1055  		return -ENXIO;
e5779998bf8b70e Daniel Mack          2010-03-04  1056  	}
e5779998bf8b70e Daniel Mack          2010-03-04  1057  
47ab154593827b1 Takashi Iwai         2015-08-25  1058  	ret = snd_usb_lock_shutdown(subs->stream->chip);
47ab154593827b1 Takashi Iwai         2015-08-25  1059  	if (ret < 0)

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