Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: rt286: Fix run time error while modifying const data

Make a copy of memory for index_cache rather than directly use the
rt286_index_def to avoid run time error.

Fixes: c418a84a8c8f ("ASoC: Constify reg_default tables")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Axel Lin and committed by
Mark Brown
dc6d84c6 6ff33f39

+6 -2
+6 -2
sound/soc/codecs/rt286.c
··· 38 38 #define RT288_VENDOR_ID 0x10ec0288 39 39 40 40 struct rt286_priv { 41 - const struct reg_default *index_cache; 41 + struct reg_default *index_cache; 42 42 int index_cache_size; 43 43 struct regmap *regmap; 44 44 struct snd_soc_codec *codec; ··· 1161 1161 return -ENODEV; 1162 1162 } 1163 1163 1164 - rt286->index_cache = rt286_index_def; 1164 + rt286->index_cache = devm_kmemdup(&i2c->dev, rt286_index_def, 1165 + sizeof(rt286_index_def), GFP_KERNEL); 1166 + if (!rt286->index_cache) 1167 + return -ENOMEM; 1168 + 1165 1169 rt286->index_cache_size = INDEX_CACHE_SIZE; 1166 1170 rt286->i2c = i2c; 1167 1171 i2c_set_clientdata(i2c, rt286);