Skip to content

Commit

Permalink
ASoC: dapm: Fix NULL pointer dereference when registering card with w…
Browse files Browse the repository at this point in the history
…idgets

Commit 0bd2ac3 ("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.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Jarkko Nikula authored and Mark Brown committed Oct 3, 2014
1 parent 0bd2ac3 commit b2d9de5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3107,7 +3107,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);
Expand Down

0 comments on commit b2d9de5

Please sign in to comment.