ASoC: io: Don't dereference regmap if we failed to get one
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 22 Jun 2012 11:40:52 +0000 (12:40 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sat, 23 Jun 2012 11:11:32 +0000 (12:11 +0100)
Avoids a crash in invalid configurations.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
sound/soc/soc-io.c

index 44d0174..29183ef 100644 (file)
@@ -145,10 +145,13 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
                if (!codec->control_data)
                        codec->control_data = dev_get_regmap(codec->dev, NULL);
 
-               ret = regmap_get_val_bytes(codec->control_data);
-               /* Errors are legitimate for non-integer byte multiples */
-               if (ret > 0)
-                       codec->val_bytes = ret;
+               if (codec->control_data) {
+                       ret = regmap_get_val_bytes(codec->control_data);
+                       /* Errors are legitimate for non-integer byte
+                        * multiples */
+                       if (ret > 0)
+                               codec->val_bytes = ret;
+               }
                break;
 
        default: