mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00:00
Merge series "ASoC: topology: fix error handling flow" from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:
While experimenting and introducing errors in Baytrail topology files
until I got them right, I encountered multiple kernel oopses and
memory leaks. This is a first batch to harden the code, but we should
probably think of a tool to fuzz the topology...
Pierre-Louis Bossart (5):
ASoC: topology: fix kernel oops on route addition error
ASoC: topology: fix tlvs in error handling for widget_dmixer
ASoC: topology: use break on errors, not continue
ASoC: topology: factor kfree(se) in error handling
ASoC: topology: add more logs when topology load fails.
sound/soc/soc-topology.c | 97 ++++++++++++++++++++++++----------------
1 file changed, 58 insertions(+), 39 deletions(-)
base-commit: a5911ac579
--
2.25.1
This commit is contained in:
commit
1e9c7ce7ad
@ -1261,17 +1261,29 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg,
|
||||
list_add(&routes[i]->dobj.list, &tplg->comp->dobj_list);
|
||||
|
||||
ret = soc_tplg_add_route(tplg, routes[i]);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
/*
|
||||
* this route was added to the list, it will
|
||||
* be freed in remove_route() so increment the
|
||||
* counter to skip it in the error handling
|
||||
* below.
|
||||
*/
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
|
||||
/* add route, but keep going if some fail */
|
||||
snd_soc_dapm_add_routes(dapm, routes[i], 1);
|
||||
}
|
||||
|
||||
/* free memory allocated for all dapm routes in case of error */
|
||||
if (ret < 0)
|
||||
for (i = 0; i < count ; i++)
|
||||
kfree(routes[i]);
|
||||
/*
|
||||
* free memory allocated for all dapm routes not added to the
|
||||
* list in case of error
|
||||
*/
|
||||
if (ret < 0) {
|
||||
while (i < count)
|
||||
kfree(routes[i++]);
|
||||
}
|
||||
|
||||
/*
|
||||
* free pointer to array of dapm routes as this is no longer needed.
|
||||
@ -1359,7 +1371,6 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
|
||||
if (err < 0) {
|
||||
dev_err(tplg->dev, "ASoC: failed to init %s\n",
|
||||
mc->hdr.name);
|
||||
soc_tplg_free_tlv(tplg, &kc[i]);
|
||||
goto err_sm;
|
||||
}
|
||||
}
|
||||
@ -1367,6 +1378,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
|
||||
|
||||
err_sm:
|
||||
for (; i >= 0; i--) {
|
||||
soc_tplg_free_tlv(tplg, &kc[i]);
|
||||
sm = (struct soc_mixer_control *)kc[i].private_value;
|
||||
kfree(sm);
|
||||
kfree(kc[i].name);
|
||||
|
Loading…
Reference in New Issue
Block a user