Skip to content

Commit c173ee5

Browse files
Amadeusz Sławińskibroonie
authored andcommitted
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: 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>
1 parent 29aab38 commit c173ee5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sound/soc/soc-topology.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,13 +1401,17 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
14011401

14021402
template.num_kcontrols = le32_to_cpu(w->num_kcontrols);
14031403
kc = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(*kc), GFP_KERNEL);
1404-
if (!kc)
1404+
if (!kc) {
1405+
ret = -ENOMEM;
14051406
goto hdr_err;
1407+
}
14061408

14071409
kcontrol_type = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(unsigned int),
14081410
GFP_KERNEL);
1409-
if (!kcontrol_type)
1411+
if (!kcontrol_type) {
1412+
ret = -ENOMEM;
14101413
goto hdr_err;
1414+
}
14111415

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

0 commit comments

Comments
 (0)