Skip to content

Commit

Permalink
ASoC: rt286: Fix run time error while modifying const data
Browse files Browse the repository at this point in the history
Make a copy of memory for index_cache rather than directly use the
rt286_index_def to avoid run time error.

Fixes: c418a84 ("ASoC: Constify reg_default tables")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Axel Lin authored and Mark Brown committed Oct 7, 2015
1 parent 6ff33f3 commit dc6d84c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sound/soc/codecs/rt286.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define RT288_VENDOR_ID 0x10ec0288

struct rt286_priv {
const struct reg_default *index_cache;
struct reg_default *index_cache;
int index_cache_size;
struct regmap *regmap;
struct snd_soc_codec *codec;
Expand Down Expand Up @@ -1161,7 +1161,11 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
return -ENODEV;
}

rt286->index_cache = rt286_index_def;
rt286->index_cache = devm_kmemdup(&i2c->dev, rt286_index_def,
sizeof(rt286_index_def), GFP_KERNEL);
if (!rt286->index_cache)
return -ENOMEM;

rt286->index_cache_size = INDEX_CACHE_SIZE;
rt286->i2c = i2c;
i2c_set_clientdata(i2c, rt286);
Expand Down

0 comments on commit dc6d84c

Please sign in to comment.