From: Mark Brown Date: Fri, 22 Jun 2012 11:40:52 +0000 (+0100) Subject: ASoC: io: Don't dereference regmap if we failed to get one X-Git-Tag: next-20120724~59^2~61 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9dfdd5abcf2b350d4fdb207c0dff3194e2fd73db;p=karo-tx-linux.git ASoC: io: Don't dereference regmap if we failed to get one Avoids a crash in invalid configurations. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 44d0174b4d97..29183ef2b93d 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -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: