ASoC: Fix soc-cache buffer overflow bug

Make sure we stay within the cache boundaries when updating the
register cache.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by Dimitris Papastamos and committed by Mark Brown d47372e8 cbfa5184

+3 -2
+3 -2
sound/soc/soc-cache.c
··· 203 203 data[1] = (value >> 8) & 0xff; 204 204 data[2] = value & 0xff; 205 205 206 - if (!snd_soc_codec_volatile_register(codec, reg)) 207 - reg_cache[reg] = value; 206 + if (!snd_soc_codec_volatile_register(codec, reg) 207 + && reg < codec->driver->reg_cache_size) 208 + reg_cache[reg] = value; 208 209 209 210 if (codec->cache_only) { 210 211 codec->cache_sync = 1;