Skip to content

Commit 304017d

Browse files
bardliaobroonie
authored andcommitted
ASoC: topology: free created components in tplg load error
Topology resources are no longer needed if any element failed to load. Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 323fb7b commit 304017d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sound/soc/soc-topology.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2487,6 +2487,7 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp,
24872487
struct snd_soc_tplg_ops *ops, const struct firmware *fw, u32 id)
24882488
{
24892489
struct soc_tplg tplg;
2490+
int ret;
24902491

24912492
/* setup parsing context */
24922493
memset(&tplg, 0, sizeof(tplg));
@@ -2500,7 +2501,12 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp,
25002501
tplg.bytes_ext_ops = ops->bytes_ext_ops;
25012502
tplg.bytes_ext_ops_count = ops->bytes_ext_ops_count;
25022503

2503-
return soc_tplg_load(&tplg);
2504+
ret = soc_tplg_load(&tplg);
2505+
/* free the created components if fail to load topology */
2506+
if (ret)
2507+
snd_soc_tplg_component_remove(comp, SND_SOC_TPLG_INDEX_ALL);
2508+
2509+
return ret;
25042510
}
25052511
EXPORT_SYMBOL_GPL(snd_soc_tplg_component_load);
25062512

0 commit comments

Comments
 (0)