Commit 2a08e63a authored by Bard liao's avatar Bard liao Committed by Kleber Sacilotto de Souza

ASoC: topology: free created components in tplg load error

BugLink: https://bugs.launchpad.net/bugs/1822271

[ Upstream commit 304017d3 ]

Topology resources are no longer needed if any element failed to load.
Signed-off-by: default avatarBard liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarJuerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 8555b52f
...@@ -1770,6 +1770,7 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp, ...@@ -1770,6 +1770,7 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp,
struct snd_soc_tplg_ops *ops, const struct firmware *fw, u32 id) struct snd_soc_tplg_ops *ops, const struct firmware *fw, u32 id)
{ {
struct soc_tplg tplg; struct soc_tplg tplg;
int ret;
/* setup parsing context */ /* setup parsing context */
memset(&tplg, 0, sizeof(tplg)); memset(&tplg, 0, sizeof(tplg));
...@@ -1783,7 +1784,12 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp, ...@@ -1783,7 +1784,12 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp,
tplg.bytes_ext_ops = ops->bytes_ext_ops; tplg.bytes_ext_ops = ops->bytes_ext_ops;
tplg.bytes_ext_ops_count = ops->bytes_ext_ops_count; tplg.bytes_ext_ops_count = ops->bytes_ext_ops_count;
return soc_tplg_load(&tplg); ret = soc_tplg_load(&tplg);
/* free the created components if fail to load topology */
if (ret)
snd_soc_tplg_component_remove(comp, SND_SOC_TPLG_INDEX_ALL);
return ret;
} }
EXPORT_SYMBOL_GPL(snd_soc_tplg_component_load); EXPORT_SYMBOL_GPL(snd_soc_tplg_component_load);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment