Commit 242c46c0 authored by Dragos Tarcatu's avatar Dragos Tarcatu Committed by Mark Brown

ASoC: topology: Fix memleak in soc_tplg_manifest_load()

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: 583958fa ("ASoC: topology: Make manifest backward compatible from ABI v4")
Signed-off-by: default avatarDragos Tarcatu <dragos_tarcatu@mentor.com>
Link: https://lore.kernel.org/r/20200207185325.22320-3-dragos_tarcatu@mentor.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2b2d5c4d
......@@ -2544,7 +2544,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;
......@@ -2557,19 +2557,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 */
......
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