ASoC: dapm: Move dai_link widgets to runtime to fix use after free
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Tue, 26 May 2020 16:19:30 +0000 (17:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:48:59 +0000 (17:48 +0200)
commite4b615bf52d69e4eb2f25f0cb5314ffae22cbd14
tree5b91d91c2d533cef531c9bbca63a5866e5d86577
parent82cb5f72ad22e7cf7ddd3e52f93c2eac6182c2db
ASoC: dapm: Move dai_link widgets to runtime to fix use after free

[ Upstream commit f4aa5e214eeaf7f1c7f157526a5aa29784cb6a1f ]

The newly added CODEC to CODEC DAI link widget pointers in
snd_soc_dai_link are better placed in snd_soc_pcm_runtime.
snd_soc_dai_link is really intended for static configuration of
the DAI, and the runtime for dynamic data.  The snd_soc_dai_link
structures are not destroyed if the card is unbound. The widgets
are cleared up on unbind, however if the card is rebound as the
snd_soc_dai_link structures are reused these pointers will be left at
their old values, causing access to freed memory.

Fixes: 595571cca4de ("ASoC: dapm: Fix regression introducing multiple copies of DAI widgets")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20200526161930.30759-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/sound/soc.h
sound/soc/soc-dapm.c