All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: damp: Reset dapm wcache after freeing damp widgets
@ 2015-11-09 13:30 Jyri Sarha
  2015-11-10 10:37 ` Charles Keepax
  2015-11-10 11:31 ` Lars-Peter Clausen
  0 siblings, 2 replies; 3+ messages in thread
From: Jyri Sarha @ 2015-11-09 13:30 UTC (permalink / raw)
  To: alsa-devel; +Cc: liam.r.girdwood, peter.ujfalusi, broonie, 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.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reported-by: Felipe Balbi <balbi@ti.com>
---
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(+)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index ff8bda4..d78db59 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -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(
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: damp: Reset dapm wcache after freeing damp widgets
  2015-11-09 13:30 [PATCH] ASoC: damp: Reset dapm wcache after freeing damp widgets Jyri Sarha
@ 2015-11-10 10:37 ` Charles Keepax
  2015-11-10 11:31 ` Lars-Peter Clausen
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2015-11-10 10:37 UTC (permalink / raw)
  To: Jyri Sarha; +Cc: liam.r.girdwood, peter.ujfalusi, alsa-devel, broonie

On Mon, Nov 09, 2015 at 03:30:26PM +0200, Jyri Sarha wrote:
> 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.
> 
> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> Reported-by: Felipe Balbi <balbi@ti.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: damp: Reset dapm wcache after freeing damp widgets
  2015-11-09 13:30 [PATCH] ASoC: damp: Reset dapm wcache after freeing damp widgets Jyri Sarha
  2015-11-10 10:37 ` Charles Keepax
@ 2015-11-10 11:31 ` Lars-Peter Clausen
  1 sibling, 0 replies; 3+ messages in thread
From: Lars-Peter Clausen @ 2015-11-10 11:31 UTC (permalink / raw)
  To: Jyri Sarha, alsa-devel; +Cc: liam.r.girdwood, peter.ujfalusi, broonie

On 11/09/2015 02:30 PM, Jyri Sarha wrote:
[...]
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index ff8bda4..d78db59 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-10 11:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-09 13:30 [PATCH] ASoC: damp: Reset dapm wcache after freeing damp widgets Jyri Sarha
2015-11-10 10:37 ` Charles Keepax
2015-11-10 11:31 ` Lars-Peter Clausen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.