summaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorBard liao <yung-chuan.liao@linux.intel.com>2019-02-17 21:23:47 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-03-23 20:09:50 +0100
commit90fc2f95c41819f33bbc95eba714df41f46280d1 (patch)
tree9b5d212bd9179f4649f6e27290668e827d2022b9 /sound/soc
parentedd7b6b9be979d8c4b0cdb3a369b636d7d397e75 (diff)
downloadlinux-stable-90fc2f95c41819f33bbc95eba714df41f46280d1.tar.gz
linux-stable-90fc2f95c41819f33bbc95eba714df41f46280d1.tar.bz2
linux-stable-90fc2f95c41819f33bbc95eba714df41f46280d1.zip
ASoC: topology: free created components in tplg load error
[ Upstream commit 304017d31df36fb61eb2ed3ebf65fb6870b3c731 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/soc-topology.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 66e77e020745..88a7e860b175 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -2493,6 +2493,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 soc_tplg tplg;
+ int ret;
/* setup parsing context */
memset(&tplg, 0, sizeof(tplg));
@@ -2506,7 +2507,12 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp,
tplg.bytes_ext_ops = ops->bytes_ext_ops;
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);