未验证 提交 c173ee5b 编写于 作者: A Amadeusz Sławiński 提交者: Mark Brown

ASoC: topology: Return -ENOMEM on memory allocation failure

When handling error path, ret needs to be set to correct value.
Reported-by: Nkernel test robot <lkp@intel.com>
Reported-by: NDan Carpenter <error27@gmail.com>
Fixes: d29d41e2 ("ASoC: topology: Add support for multiple kcontrol types to a widget")
Reviewed-by: NCezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: NAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230207210428.2076354-1-amadeuszx.slawinski@linux.intel.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 29aab388
...@@ -1401,13 +1401,17 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, ...@@ -1401,13 +1401,17 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
template.num_kcontrols = le32_to_cpu(w->num_kcontrols); template.num_kcontrols = le32_to_cpu(w->num_kcontrols);
kc = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(*kc), GFP_KERNEL); kc = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(*kc), GFP_KERNEL);
if (!kc) if (!kc) {
ret = -ENOMEM;
goto hdr_err; goto hdr_err;
}
kcontrol_type = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(unsigned int), kcontrol_type = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
if (!kcontrol_type) if (!kcontrol_type) {
ret = -ENOMEM;
goto hdr_err; goto hdr_err;
}
for (i = 0; i < le32_to_cpu(w->num_kcontrols); i++) { for (i = 0; i < le32_to_cpu(w->num_kcontrols); i++) {
control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos; control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册