Skip to content

Commit

Permalink
soc: fix a use after free case
Browse files Browse the repository at this point in the history
Unloading ASoC modules as used by the SOF driver leads to an object
being used after it's been freed. Fix this be clearing a reference to
it and making sure to check for its presence. This fixes issue torvalds#144.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
(cherry picked from commit 0576373)
  • Loading branch information
lyakh authored and ranj063 committed Nov 9, 2018
1 parent f74fcf8 commit a5c9b05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ static void soc_remove_dai(struct snd_soc_dai *dai, int order)
{
int err;

if (!dai || !dai->probed ||
if (!dai || !dai->probed || !dai->driver ||
dai->driver->remove_order != order)
return;

Expand Down
5 changes: 5 additions & 0 deletions sound/soc/soc-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,18 @@ static void remove_dai(struct snd_soc_component *comp,
{
struct snd_soc_dai_driver *dai_drv =
container_of(dobj, struct snd_soc_dai_driver, dobj);
struct snd_soc_dai *dai;

if (pass != SOC_TPLG_PASS_PCM_DAI)
return;

if (dobj->ops && dobj->ops->dai_unload)
dobj->ops->dai_unload(comp, dobj);

list_for_each_entry(dai, &comp->dai_list, list)
if (dai->driver == dai_drv)
dai->driver = NULL;

kfree(dai_drv->name);
list_del(&dobj->list);
kfree(dai_drv);
Expand Down

0 comments on commit a5c9b05

Please sign in to comment.