Skip to contentSkip to conversation

ASoC: damp: Reset dapm wcache after freeing damp widgets

PATCH Superseded Jyri Sarha 3 participants 3 messages Nov 9, 2015 – Nov 10, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jyri Sarha

author
#0 lore raw

PATCH 1/1 ASoC: damp: Reset dapm wcache after freeing damp widgets

If there is anything in damp->path_source_cache or damp->path_sink_cache, it can not be valid after the widgets have been freed. Without this patch a repeated remove and load of a machine driver may cause NULL pointer reference in dapm_wcache_lookup() when a freed widget, not belonging to any list, is haunting in the wcache.

---
The patch fixes the problem reported here:
http://mailman.alsa-project.org/pipermail/alsa-devel/2015-October/099431.html

 sound/soc/soc-dapm.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/soc-dapm.c +3 -0
index ff8bda4..d78db59 100644
@@ -2286,6 +2286,9 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm)
 			continue;
 		snd_soc_dapm_free_widget(w);
 	}
+
+	dapm->path_sink_cache.widget = NULL;
+	dapm->path_source_cache.widget = NULL;
 }
 
 static struct snd_soc_dapm_widget *dapm_find_widget(
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jyri Sarha

If there is anything in damp->path_source_cache or damp->path_sink_cache, it can not be valid after the widgets have been freed. Without this patch a repeated remove and load of a machine driver may cause NULL pointer reference in dapm_wcache_lookup() when a freed widget, not belonging to any list, is haunting in the wcache.

---

Thanks,
Charles

#2 lore raw
In reply to Jyri Sarha

On 11/09/2015 02:30 PM, Jyri Sarha wrote:
[...]

sound/soc/soc-dapm.c static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) · line 2292

Quoted 12 lines
sound/soc/soc-dapm.c +3 -0
index ff8bda4..d78db59 100644
@@ -2286,6 +2286,9 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm)
 			continue;
 		snd_soc_dapm_free_widget(w);
 	}
+
+	dapm->path_sink_cache.widget = NULL;
+	dapm->path_source_cache.widget = NULL;
 }

Looks good, but this is not the only place where we free widgets. Can you add a helper function snd_soc_dapm_reset_cache() (or similar) and then call this from dapm_free_widgets() as well as snd_soc_tplg_widget_remove_all().

- Lars