summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDragos Tarcatu <dragos_tarcatu@mentor.com>2020-02-07 21:53:25 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-03-11 16:15:07 +0300
commit8a622e6db8764794bcfe8c30b63bfe0a0a122646 (patch)
tree7f0f53e3abfa76314558b21af5a19a5feee59623
parenta7d675643ed8902f0a702d1dbe6ec4f9ec9b546c (diff)
downloadlinux-8a622e6db8764794bcfe8c30b63bfe0a0a122646.tar.xz
ASoC: topology: Fix memleak in soc_tplg_manifest_load()
commit 242c46c023610dbc0213fc8fb6b71eb836bc5d95 upstream. In case of ABI version mismatch, _manifest needs to be freed as it is just a copy of the original topology manifest. However, if a driver manifest handler is defined, that would get executed and the cleanup is never reached. Fix that by getting the return status of manifest() instead of returning directly. Fixes: 583958fa2e52 ("ASoC: topology: Make manifest backward compatible from ABI v4") Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com> Link: https://lore.kernel.org/r/20200207185325.22320-3-dragos_tarcatu@mentor.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--sound/soc/soc-topology.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index c56cdeb10601..30fc45aa1869 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -2313,7 +2313,7 @@ static int soc_tplg_manifest_load(struct soc_tplg *tplg,
{
struct snd_soc_tplg_manifest *manifest, *_manifest;
bool abi_match;
- int err;
+ int ret = 0;
if (tplg->pass != SOC_TPLG_PASS_MANIFEST)
return 0;
@@ -2326,19 +2326,19 @@ static int soc_tplg_manifest_load(struct soc_tplg *tplg,
_manifest = manifest;
} else {
abi_match = false;
- err = manifest_new_ver(tplg, manifest, &_manifest);
- if (err < 0)
- return err;
+ ret = manifest_new_ver(tplg, manifest, &_manifest);
+ if (ret < 0)
+ return ret;
}
/* pass control to component driver for optional further init */
if (tplg->comp && tplg->ops && tplg->ops->manifest)
- return tplg->ops->manifest(tplg->comp, tplg->index, _manifest);
+ ret = tplg->ops->manifest(tplg->comp, tplg->index, _manifest);
if (!abi_match) /* free the duplicated one */
kfree(_manifest);
- return 0;
+ return ret;
}
/* validate header magic, size and type */