Skip to contentSkip to conversation

drivers/soundwire/stream.c:1557 sdw_prepare_stream() warn: variable dereferenced before check 'stream' (see line 1555)

PATCH New Dan Carpenter 1 participant 1 message Oct 26, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 51/53 drivers/soundwire/stream.c:1557 sdw_prepare_stream() warn: variable dereferenced before check 'stream' (see line 1555)

tree:   https://github.com/plbossart/sound integration/soundwire-20191022
head:   40ac17aeeb4954510b3db3a8314fa5ab3a0169f6
commit: 8b1325343c5c750a0b25120bf354c7a73cfda4c6 [51/53] [HACK] add traces to debug aplay suspend/resume issue

If you fix the issue, kindly add following tag

New smatch warnings:
drivers/soundwire/stream.c:1557 sdw_prepare_stream() warn: variable dereferenced before check 'stream' (see line 1555) drivers/soundwire/stream.c:1655 sdw_enable_stream() warn: variable dereferenced before check 'stream' (see line 1653) drivers/soundwire/stream.c:1744 sdw_disable_stream() warn: variable dereferenced before check 'stream' (see line 1742) drivers/soundwire/stream.c:1816 sdw_deprepare_stream() warn: variable dereferenced before check 'stream' (see line 1814)

Old smatch warnings:
drivers/soundwire/stream.c:102 _sdw_program_slave_port_params() warn: '(t_params->sample_interval - 1)' 4294967295 can't fit into 65535 'wbuf' include/linux/compiler.h:226 __write_once_size() warn: potential memory corrupting cast 8 vs 4 bytes

# https://github.com/plbossart/sound/commit/8b1325343c5c750a0b25120bf354c7a73cfda4c6
git remote add plbossart-sound https://github.com/plbossart/sound
git remote update plbossart-sound
git checkout 8b1325343c5c750a0b25120bf354c7a73cfda4c6
vim +/stream +1557 drivers/soundwire/stream.c

5c3eb9f7bdf1f1 Sanyog Kale           2018-04-26  1550  int sdw_prepare_stream(struct sdw_stream_runtime *stream)
5c3eb9f7bdf1f1 Sanyog Kale           2018-04-26  1551  {
564e8992e95ea1 Pierre-Louis Bossart  2019-10-15  1552  	bool update_params = true;
36269dcfbd2d7f Bard Liao             2019-09-20  1553  	int ret;
5c3eb9f7bdf1f1 Sanyog Kale           2018-04-26  1554  
8b1325343c5c75 Pierre-Louis Bossart  2019-10-12 @1555  	pr_err("%s: %s start\n", __func__, stream->name);
                                                                                           ^^^^^^^^^^^^

Unchecked dereference.

8b1325343c5c75 Pierre-Louis Bossart 2019-10-12 1556

5c3eb9f7bdf1f1 Sanyog Kale           2018-04-26 @1557  	if (!stream) {
                                                            ^^^^^^^

Too late.

17ed5bef49f42e Pierre-Louis Bossart  2019-05-01  1558  		pr_err("SoundWire: Handle not found for stream\n");
5c3eb9f7bdf1f1 Sanyog Kale           2018-04-26  1559  		return -EINVAL;
5c3eb9f7bdf1f1 Sanyog Kale           2018-04-26  1560  	}
5c3eb9f7bdf1f1 Sanyog Kale           2018-04-26  1561  
48949722ced4da Vinod Koul            2018-07-27  1562  	sdw_acquire_bus_lock(stream);
5c3eb9f7bdf1f1 Sanyog Kale           2018-04-26  1563  
36269dcfbd2d7f Bard Liao             2019-09-20  1564  	if (stream->state == SDW_STREAM_PREPARED) {
36269dcfbd2d7f Bard Liao             2019-09-20  1565  		ret = 0;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation