OSDN Git Service

ASoC: dapm: Fix NULL pointer dereference when registering card with widgets
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Fri, 3 Oct 2014 12:32:40 +0000 (15:32 +0300)
committerMark Brown <broonie@kernel.org>
Fri, 3 Oct 2014 14:39:19 +0000 (15:39 +0100)
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.

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>
sound/soc/soc-dapm.c

index 1f1e965..231deb2 100644 (file)
@@ -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);