Skip to content

Commit

Permalink
ASoC: io: Don't dereference regmap if we failed to get one
Browse files Browse the repository at this point in the history
Avoids a crash in invalid configurations.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
  • Loading branch information
Mark Brown committed Jun 23, 2012
1 parent 62d4a4b commit 9dfdd5a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sound/soc/soc-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9dfdd5a

Please sign in to comment.