ASoC: Check for a CODEC before dereferencing in DAPM
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 2 Mar 2011 18:18:24 +0000 (18:18 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 3 Mar 2011 11:15:03 +0000 (11:15 +0000)
A CODEC pointer is optional (and is checked for in most contexts within
DAPM) - add checks to the few places where it was missed.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
sound/soc/soc-dapm.c

index 8240ab8..570db88 100644 (file)
@@ -1517,7 +1517,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
        char prefixed_source[80];
        int ret = 0;
 
-       if (dapm->codec->name_prefix) {
+       if (dapm->codec && dapm->codec->name_prefix) {
                snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
                         dapm->codec->name_prefix, route->sink);
                sink = prefixed_sink;
@@ -2167,14 +2167,14 @@ int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
                return -ENOMEM;
 
        name_len = strlen(widget->name) + 1;
-       if (dapm->codec->name_prefix)
+       if (dapm->codec && dapm->codec->name_prefix)
                name_len += 1 + strlen(dapm->codec->name_prefix);
        w->name = kmalloc(name_len, GFP_KERNEL);
        if (w->name == NULL) {
                kfree(w);
                return -ENOMEM;
        }
-       if (dapm->codec->name_prefix)
+       if (dapm->codec && dapm->codec->name_prefix)
                snprintf(w->name, name_len, "%s %s",
                        dapm->codec->name_prefix, widget->name);
        else