Skip to content

Commit dd836dd

Browse files
Dragos Tarcatubroonie
authored andcommitted
ASoC: topology: Prevent use-after-free in snd_soc_get_pcm_runtime()
remove_link() is currently calling snd_soc_remove_dai_link() after it has already freed the memory for the link name. But this is later read from snd_soc_get_pcm_runtime() causing a KASAN use-after-free warning. Reorder the cleanups to fix this issue. Reviewed-by: Ranjani Sridharan <[email protected]> Signed-off-by: Dragos Tarcatu <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Kuninori Morimoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 77fffa7 commit dd836dd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sound/soc/soc-topology.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,12 @@ static void remove_link(struct snd_soc_component *comp,
548548
if (dobj->ops && dobj->ops->link_unload)
549549
dobj->ops->link_unload(comp, dobj);
550550

551+
list_del(&dobj->list);
552+
snd_soc_remove_dai_link(comp->card, link);
553+
551554
kfree(link->name);
552555
kfree(link->stream_name);
553556
kfree(link->cpus->dai_name);
554-
555-
list_del(&dobj->list);
556-
snd_soc_remove_dai_link(comp->card, link);
557557
kfree(link);
558558
}
559559

0 commit comments

Comments
 (0)