]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/asoc-topology-free-created-components-in-tplg-load-e.patch
Linux 4.14.108
[thirdparty/kernel/stable-queue.git] / queue-4.19 / asoc-topology-free-created-components-in-tplg-load-e.patch
1 From 7c91c214141c74c160df9588f3012947d8e4cbb3 Mon Sep 17 00:00:00 2001
2 From: Bard liao <yung-chuan.liao@linux.intel.com>
3 Date: Sun, 17 Feb 2019 21:23:47 +0800
4 Subject: ASoC: topology: free created components in tplg load error
5
6 [ Upstream commit 304017d31df36fb61eb2ed3ebf65fb6870b3c731 ]
7
8 Topology resources are no longer needed if any element failed to load.
9
10 Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
11 Signed-off-by: Mark Brown <broonie@kernel.org>
12 Signed-off-by: Sasha Levin <sashal@kernel.org>
13 ---
14 sound/soc/soc-topology.c | 8 +++++++-
15 1 file changed, 7 insertions(+), 1 deletion(-)
16
17 diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
18 index 66e77e020745..88a7e860b175 100644
19 --- a/sound/soc/soc-topology.c
20 +++ b/sound/soc/soc-topology.c
21 @@ -2493,6 +2493,7 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp,
22 struct snd_soc_tplg_ops *ops, const struct firmware *fw, u32 id)
23 {
24 struct soc_tplg tplg;
25 + int ret;
26
27 /* setup parsing context */
28 memset(&tplg, 0, sizeof(tplg));
29 @@ -2506,7 +2507,12 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp,
30 tplg.bytes_ext_ops = ops->bytes_ext_ops;
31 tplg.bytes_ext_ops_count = ops->bytes_ext_ops_count;
32
33 - return soc_tplg_load(&tplg);
34 + ret = soc_tplg_load(&tplg);
35 + /* free the created components if fail to load topology */
36 + if (ret)
37 + snd_soc_tplg_component_remove(comp, SND_SOC_TPLG_INDEX_ALL);
38 +
39 + return ret;
40 }
41 EXPORT_SYMBOL_GPL(snd_soc_tplg_component_load);
42
43 --
44 2.19.1
45