Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: simple-card: fix possible uninitialized single_cpu local variable

The 'single_cpu' local variable is assigned by asoc_simple_parse_dai()
and later used in a asoc_simple_canonicalize_cpu() call, assuming the
entire function did not exit on errors.

However the first function returns 0 if passed device_node is NULL,
thus leaving the variable uninitialized and reporting success.

Addresses-Coverity: Uninitialized scalar variable
Fixes: 8f7f298a3337 ("ASoC: simple-card-utils: separate asoc_simple_card_parse_dai()")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Acked-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/20210407092027.60769-1-krzysztof.kozlowski@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
fa74c223 af4b5412

+2 -2
+1 -1
sound/soc/generic/audio-graph-card.c
··· 367 367 struct device_node *top = dev->of_node; 368 368 struct asoc_simple_dai *cpu_dai; 369 369 struct asoc_simple_dai *codec_dai; 370 - int ret, single_cpu; 370 + int ret, single_cpu = 0; 371 371 372 372 dev_dbg(dev, "link_of (%pOF)\n", cpu_ep); 373 373
+1 -1
sound/soc/generic/simple-card.c
··· 249 249 struct device_node *plat = NULL; 250 250 char prop[128]; 251 251 char *prefix = ""; 252 - int ret, single_cpu; 252 + int ret, single_cpu = 0; 253 253 254 254 cpu = np; 255 255 node = of_get_parent(np);