From: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Subject: [PATCH] ASoC: fix a use after free case
Date: Fri, 21 Sep 2018 16:59:35 +0200 [thread overview]
Message-ID: <20180921145934.GD28693@kadasd710.ka.intel.com> (raw)
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 #144.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
---
sound/soc/soc-core.c | 6 +++---
sound/soc/soc-topology.c | 5 +++++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9cfe10d8040c..dce9d53ff283 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -942,9 +942,9 @@ static void soc_remove_dai(struct snd_soc_dai *dai, int order)
{
int err;
- if (dai && dai->probed &&
- dai->driver->remove_order == order) {
- if (dai->driver->remove) {
+ if (dai && dai->probed) {
+ if (dai->driver && dai->driver->remove_order == order &&
+ dai->driver->remove) {
err = dai->driver->remove(dai);
if (err < 0)
dev_err(dai->dev,
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 66e77e020745..6d438ec8c0ec 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -502,6 +502,7 @@ 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;
@@ -509,6 +510,10 @@ static void remove_dai(struct snd_soc_component *comp,
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);
--
2.17.1
reply other threads:[~2018-09-21 14:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180921145934.GD28693@kadasd710.ka.intel.com \
--to=guennadi.liakhovetski@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=liam.r.girdwood@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox