Skip to content

Commit 242c46c

Browse files
Dragos Tarcatubroonie
authored andcommitted
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: 583958f ("ASoC: topology: Make manifest backward compatible from ABI v4") Signed-off-by: Dragos Tarcatu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2b2d5c4 commit 242c46c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sound/soc/soc-topology.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,7 @@ static int soc_tplg_manifest_load(struct soc_tplg *tplg,
25442544
{
25452545
struct snd_soc_tplg_manifest *manifest, *_manifest;
25462546
bool abi_match;
2547-
int err;
2547+
int ret = 0;
25482548

25492549
if (tplg->pass != SOC_TPLG_PASS_MANIFEST)
25502550
return 0;
@@ -2557,19 +2557,19 @@ static int soc_tplg_manifest_load(struct soc_tplg *tplg,
25572557
_manifest = manifest;
25582558
} else {
25592559
abi_match = false;
2560-
err = manifest_new_ver(tplg, manifest, &_manifest);
2561-
if (err < 0)
2562-
return err;
2560+
ret = manifest_new_ver(tplg, manifest, &_manifest);
2561+
if (ret < 0)
2562+
return ret;
25632563
}
25642564

25652565
/* pass control to component driver for optional further init */
25662566
if (tplg->comp && tplg->ops && tplg->ops->manifest)
2567-
return tplg->ops->manifest(tplg->comp, tplg->index, _manifest);
2567+
ret = tplg->ops->manifest(tplg->comp, tplg->index, _manifest);
25682568

25692569
if (!abi_match) /* free the duplicated one */
25702570
kfree(_manifest);
25712571

2572-
return 0;
2572+
return ret;
25732573
}
25742574

25752575
/* validate header magic, size and type */

0 commit comments

Comments
 (0)