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

ASoC: topology: Return -ENOMEM on memory allocation failure

When handling error path, ret needs to be set to correct value.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Fixes: d29d41e28eea ("ASoC: topology: Add support for multiple kcontrol types to a widget")
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230207210428.2076354-1-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Amadeusz Sławiński and committed by
Mark Brown
c173ee5b 29aab388

+6 -2
+6 -2
sound/soc/soc-topology.c
··· 1401 1401 1402 1402 template.num_kcontrols = le32_to_cpu(w->num_kcontrols); 1403 1403 kc = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(*kc), GFP_KERNEL); 1404 - if (!kc) 1404 + if (!kc) { 1405 + ret = -ENOMEM; 1405 1406 goto hdr_err; 1407 + } 1406 1408 1407 1409 kcontrol_type = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(unsigned int), 1408 1410 GFP_KERNEL); 1409 - if (!kcontrol_type) 1411 + if (!kcontrol_type) { 1412 + ret = -ENOMEM; 1410 1413 goto hdr_err; 1414 + } 1411 1415 1412 1416 for (i = 0; i < le32_to_cpu(w->num_kcontrols); i++) { 1413 1417 control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos;