lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202203290343.9cbKTLxo-lkp@intel.com>
Date:   Tue, 29 Mar 2022 11:04:18 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Richard Fitzgerald <rf@...nsource.cirrus.com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org, Mark Brown <broonie@...nel.org>
Subject: sound/soc/generic/simple-card-utils.c:367 asoc_simple_set_tdm()
 warn: variable dereferenced before check 'simple_dai' (see line 363)

[ I reported some related bugs earlier but not this exact one. -dan ]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   ae085d7f9365de7da27ab5c0d16b12d51ea7fca9
commit: 1e974e5b82b3d75069b50445cd248cee0199654e ASoC: audio_graph_card2: Add support for variable slot widths
config: riscv-randconfig-m031-20220327 (https://download.01.org/0day-ci/archive/20220329/202203290343.9cbKTLxo-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

smatch warnings:
sound/soc/generic/simple-card-utils.c:367 asoc_simple_set_tdm() warn: variable dereferenced before check 'simple_dai' (see line 363)

vim +/simple_dai +367 sound/soc/generic/simple-card-utils.c

1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  358  static int asoc_simple_set_tdm(struct snd_soc_dai *dai,
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  359  				struct asoc_simple_dai *simple_dai,
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  360  				struct snd_pcm_hw_params *params)
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  361  {
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  362  	int sample_bits = params_width(params);
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28 @363  	int slot_width = simple_dai->slot_width;
                                                                         ^^^^^^^^^^^^^^^^^^^^^^
Dereference

1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  364  	int slot_count = simple_dai->slots;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  365  	int i, ret;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  366  
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28 @367  	if (!simple_dai || !simple_dai->tdm_width_map)
                                                             ^^^^^^^^^^
Checked too late.

1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  368  		return 0;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  369  
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  370  	if (slot_width == 0)
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  371  		slot_width = sample_bits;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  372  
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  373  	for (i = 0; i < simple_dai->n_tdm_widths; ++i) {
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  374  		if (simple_dai->tdm_width_map[i].sample_bits == sample_bits) {
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  375  			slot_width = simple_dai->tdm_width_map[i].slot_width;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  376  			slot_count = simple_dai->tdm_width_map[i].slot_count;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  377  			break;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  378  		}
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  379  	}
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  380  
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  381  	ret = snd_soc_dai_set_tdm_slot(dai,
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  382  				       simple_dai->tx_slot_mask,
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  383  				       simple_dai->rx_slot_mask,
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  384  				       slot_count,
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  385  				       slot_width);
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  386  	if (ret && ret != -ENOTSUPP) {
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  387  		dev_err(dai->dev, "simple-card: set_tdm_slot error: %d\n", ret);
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  388  		return ret;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  389  	}
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  390  
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  391  	return 0;
1e974e5b82b3d7 Richard Fitzgerald 2022-02-28  392  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ