Skip to contentSkip to conversation

ASoC: dapm: Fix NULL pointer dereference when registering card with widgets

PATCH Applied Jarkko Nikula 3 participants 3 messages Oct 3, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: dapm: Fix NULL pointer dereference when registering card with widgets

Commit 0bd2ac3dae74 ("ASoC: Remove CODEC pointer from snd_soc_dapm_context") introduced regression to snd_soc_dapm_new_controls() when registering a card with card->dapm_widgets set. Call chain is:

    snd_soc_register_card()
    -> snd_soc_instantiate_card()
       -> snd_soc_dapm_new_controls()
          -> snd_soc_dapm_new_control()

Null pointer dereference occurs since card->dapm context doesn't have associated component. Fix this by setting widget codec pointer conditionally.

---
 sound/soc/soc-dapm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/soc-dapm.c +2 -1
index 2d06892088d5..3f0b4108f7ca 100644
@@ -3125,7 +3125,8 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
 	}
 
 	w->dapm = dapm;
-	w->codec = dapm->component->codec;
+	if (dapm->component)
+		w->codec = dapm->component->codec;
 	INIT_LIST_HEAD(&w->sources);
 	INIT_LIST_HEAD(&w->sinks);
 	INIT_LIST_HEAD(&w->list);
Signature · 1 line
2.1.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jarkko Nikula

Commit 0bd2ac3dae74 ("ASoC: Remove CODEC pointer from snd_soc_dapm_context") introduced regression to snd_soc_dapm_new_controls() when registering a card with card->dapm_widgets set. Call chain is:

     snd_soc_register_card()
     -> snd_soc_instantiate_card()
        -> snd_soc_dapm_new_controls()
           -> snd_soc_dapm_new_control()
Quoted 5 lines

Null pointer dereference occurs since card->dapm context doesn't have associated component. Fix this by setting widget codec pointer conditionally.

Thanks. Stupid mistake.

maintainer Applied
#2 lore raw
In reply to Jarkko Nikula
Quoted 3 lines · Jarkko Nikula

Commit 0bd2ac3dae74 ("ASoC: Remove CODEC pointer from snd_soc_dapm_context") introduced regression to snd_soc_dapm_new_controls() when registering a card with card->dapm_widgets set. Call chain is:

Applied, thanks.