Skip to content

Commit

Permalink
ASoC: topology: Return -ENOMEM on memory allocation failure
Browse files Browse the repository at this point in the history
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: d29d41e ("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>
  • Loading branch information
Amadeusz Sławiński authored and Mark Brown committed Feb 7, 2023
1 parent 29aab38 commit c173ee5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sound/soc/soc-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,13 +1401,17 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,

template.num_kcontrols = le32_to_cpu(w->num_kcontrols);
kc = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(*kc), GFP_KERNEL);
if (!kc)
if (!kc) {
ret = -ENOMEM;
goto hdr_err;
}

kcontrol_type = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(unsigned int),
GFP_KERNEL);
if (!kcontrol_type)
if (!kcontrol_type) {
ret = -ENOMEM;
goto hdr_err;
}

for (i = 0; i < le32_to_cpu(w->num_kcontrols); i++) {
control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos;
Expand Down

0 comments on commit c173ee5

Please sign in to comment.