sound/soc/generic/simple-card.c:259:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]

From: kernel test robot
Date: Mon Aug 23 2021 - 23:35:08 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d5ae8d7f85b7f6f6e60f1af8ff4be52b0926fde1
commit: 6ad76b573bb63ef229cf60386cc38c6e7c7625d7 ASoC: simple-card: add simple_link_init()
date: 4 months ago
config: arm-randconfig-c002-20210816 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 44d0a99a12ec7ead4d2f5ef649ba05b40f6d463d)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6ad76b573bb63ef229cf60386cc38c6e7c7625d7
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 6ad76b573bb63ef229cf60386cc38c6e7c7625d7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


clang-analyzer warnings: (new ones prefixed by >>)
4 warnings generated.
sound/soc/codecs/pcm186x.c:268:19: warning: Value stored to 'format' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
snd_pcm_format_t format = params_format(params);
^~~~~~ ~~~~~~~~~~~~~~~~~~~~~
sound/soc/codecs/pcm186x.c:268:19: note: Value stored to 'format' during its initialization is never read
snd_pcm_format_t format = params_format(params);
^~~~~~ ~~~~~~~~~~~~~~~~~~~~~
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
drivers/hid/hid-sensor-custom.c:407:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = sensor_hub_set_feature(sensor_inst->hsdev, report_id,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hid/hid-sensor-custom.c:407:3: note: Value stored to 'ret' is never read
ret = sensor_hub_set_feature(sensor_inst->hsdev, report_id,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 3 warnings (2 in non-user code, 1 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (2 in non-user code, 2 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
>> sound/soc/generic/simple-card.c:259:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device *dev = simple_priv_to_dev(priv);
^~~
sound/soc/generic/simple-card.c:259:17: note: Value stored to 'dev' during its initialization is never read
struct device *dev = simple_priv_to_dev(priv);
^~~
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
sound/soc/generic/audio-graph-card.c:367:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device *dev = simple_priv_to_dev(priv);
^~~
sound/soc/generic/audio-graph-card.c:367:17: note: Value stored to 'dev' during its initialization is never read
struct device *dev = simple_priv_to_dev(priv);
^~~
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
sound/core/seq/seq_clientmgr.c:1228:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
strcpy(info->name, cptr->name);
^~~~~~
sound/core/seq/seq_clientmgr.c:1228:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
strcpy(info->name, cptr->name);
^~~~~~
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
arch/arm/include/asm/uaccess.h:567:2: warning: Null pointer passed as 2nd argument to memory copy function [clang-analyzer-unix.cstring.NullArg]
memcpy(to, (const void __force *)from, n);
^
sound/core/seq/seq_memory.c:291:6: note: Assuming the condition is true
if (snd_seq_ev_is_variable(event)) {
^
include/sound/asequencer.h:55:37: note: expanded from macro 'snd_seq_ev_is_variable'
#define snd_seq_ev_is_variable(ev) (snd_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARIABLE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/sound/asequencer.h:53:36: note: expanded from macro 'snd_seq_ev_length_type'
#define snd_seq_ev_length_type(ev) ((ev)->flags & SNDRV_SEQ_EVENT_LENGTH_MASK)
^
sound/core/seq/seq_memory.c:291:2: note: Taking true branch
if (snd_seq_ev_is_variable(event)) {
^
sound/core/seq/seq_memory.c:295:6: note: Assuming 'ncells' is < field 'total_elements'
if (ncells >= pool->total_elements)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/seq/seq_memory.c:295:2: note: Taking false branch
if (ncells >= pool->total_elements)
^
sound/core/seq/seq_memory.c:299:6: note: Assuming 'err' is >= 0
if (err < 0)
^~~~~~~
sound/core/seq/seq_memory.c:299:2: note: Taking false branch
if (err < 0)
^
sound/core/seq/seq_memory.c:306:2: note: Taking true branch
if (snd_seq_ev_is_variable(event)) {
^
sound/core/seq/seq_memory.c:317:3: note: The value of 'src' is assigned to 'buf'
buf = (char *)event->data.ext.ptr;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/seq/seq_memory.c:320:10: note: Assuming the condition is true
while (ncells-- > 0) {
^~~~~~~~~~~~
sound/core/seq/seq_memory.c:320:3: note: Loop condition is true. Entering loop body
while (ncells-- > 0) {
^
sound/core/seq/seq_memory.c:322:8: note: Assuming 'len' is >= 'size'
if (len < size)

vim +/dev +259 sound/soc/generic/simple-card.c

da215354eb55c3 Kuninori Morimoto 2018-12-14 252
e59289cda8dec0 Kuninori Morimoto 2019-03-20 253 static int simple_dai_link_of(struct asoc_simple_priv *priv,
d947cdfd4be29c Kuninori Morimoto 2018-12-20 254 struct device_node *np,
d947cdfd4be29c Kuninori Morimoto 2018-12-20 255 struct device_node *codec,
17029e494edc68 Kuninori Morimoto 2018-12-20 256 struct link_info *li,
d947cdfd4be29c Kuninori Morimoto 2018-12-20 257 bool is_top)
6a91a17bd7b92b Jean-Francois Moine 2014-03-20 258 {
f531913f01a072 Kuninori Morimoto 2014-09-09 @259 struct device *dev = simple_priv_to_dev(priv);
17029e494edc68 Kuninori Morimoto 2018-12-20 260 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
5bb5ac71e3f4f8 Kuninori Morimoto 2021-04-14 261 struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0);
5bb5ac71e3f4f8 Kuninori Morimoto 2021-04-14 262 struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0);
5bb5ac71e3f4f8 Kuninori Morimoto 2021-04-14 263 struct snd_soc_dai_link_component *platforms = asoc_link_to_platform(dai_link, 0);
1b5721b24306c2 Kuninori Morimoto 2014-10-27 264 struct device_node *cpu = NULL;
d947cdfd4be29c Kuninori Morimoto 2018-12-20 265 struct device_node *node = NULL;
e0ae225b7e96e5 Jun Nie 2015-04-29 266 struct device_node *plat = NULL;
6ad76b573bb63e Kuninori Morimoto 2021-05-11 267 char dai_name[64];
b3ca11ff59bc58 Jyri Sarha 2014-03-24 268 char prop[128];
b3ca11ff59bc58 Jyri Sarha 2014-03-24 269 char *prefix = "";
25c4a9b614f101 Mark Brown 2021-04-23 270 int ret, single_cpu = 0;
6a91a17bd7b92b Jean-Francois Moine 2014-03-20 271
d947cdfd4be29c Kuninori Morimoto 2018-12-20 272 cpu = np;
d947cdfd4be29c Kuninori Morimoto 2018-12-20 273 node = of_get_parent(np);
17029e494edc68 Kuninori Morimoto 2018-12-20 274
17029e494edc68 Kuninori Morimoto 2018-12-20 275 dev_dbg(dev, "link_of (%pOF)\n", node);
17029e494edc68 Kuninori Morimoto 2018-12-20 276
2080437d375f4d Xiubo Li 2014-09-03 277 /* For single DAI link & old style of DT node */
d947cdfd4be29c Kuninori Morimoto 2018-12-20 278 if (is_top)
548563fa3e430c Kuninori Morimoto 2016-05-31 279 prefix = PREFIX;
b3ca11ff59bc58 Jyri Sarha 2014-03-24 280
e0ae225b7e96e5 Jun Nie 2015-04-29 281 snprintf(prop, sizeof(prop), "%splat", prefix);
e0ae225b7e96e5 Jun Nie 2015-04-29 282 plat = of_get_child_by_name(node, prop);
e0ae225b7e96e5 Jun Nie 2015-04-29 283
0919a3acc0c870 Kuninori Morimoto 2021-05-11 284 ret = simple_parse_node(priv, cpu, li, prefix, &single_cpu);
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 285 if (ret < 0)
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 286 goto dai_link_of_err;
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 287
0919a3acc0c870 Kuninori Morimoto 2021-05-11 288 ret = simple_parse_node(priv, codec, li, prefix, NULL);
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 289 if (ret < 0)
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 290 goto dai_link_of_err;
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 291
5bb5ac71e3f4f8 Kuninori Morimoto 2021-04-14 292 ret = asoc_simple_parse_dai(plat, platforms, NULL);
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 293 if (ret < 0)
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 294 goto dai_link_of_err;
44c16af1fa8a5b Kuninori Morimoto 2016-08-08 295
6ad76b573bb63e Kuninori Morimoto 2021-05-11 296 snprintf(dai_name, sizeof(dai_name),
6ad76b573bb63e Kuninori Morimoto 2021-05-11 297 "%s-%s", cpus->dai_name, codecs->dai_name);
25c4a9b614f101 Mark Brown 2021-04-23 298
25c4a9b614f101 Mark Brown 2021-04-23 299 asoc_simple_canonicalize_cpu(cpus, single_cpu);
25c4a9b614f101 Mark Brown 2021-04-23 300 asoc_simple_canonicalize_platform(platforms, cpus);
25c4a9b614f101 Mark Brown 2021-04-23 301
6ad76b573bb63e Kuninori Morimoto 2021-05-11 302 ret = simple_link_init(priv, node, codec, li, prefix, dai_name);
6ad76b573bb63e Kuninori Morimoto 2021-05-11 303
b3ca11ff59bc58 Jyri Sarha 2014-03-24 304 dai_link_of_err:
44662f90cda7ce Takashi Iwai 2019-02-19 305 of_node_put(plat);
d947cdfd4be29c Kuninori Morimoto 2018-12-20 306 of_node_put(node);
1b5721b24306c2 Kuninori Morimoto 2014-10-27 307
0919a3acc0c870 Kuninori Morimoto 2021-05-11 308 li->link++;
0919a3acc0c870 Kuninori Morimoto 2021-05-11 309
6a91a17bd7b92b Jean-Francois Moine 2014-03-20 310 return ret;
6a91a17bd7b92b Jean-Francois Moine 2014-03-20 311 }
6a91a17bd7b92b Jean-Francois Moine 2014-03-20 312

:::::: The code at line 259 was first introduced by commit
:::::: f531913f01a07253d013a9c67a80df11154e7ae2 ASoC: simple-card: tidyup use priv in parameter

:::::: TO: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
:::::: CC: Mark Brown <broonie@xxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip