diff mbox

Regarding ASoC: rt286: Fix the runtime error in the booting

Message ID 1444039739.8819.2.camel@ingics.com (mailing list archive)
State New, archived
Headers show

Commit Message

Axel Lin Oct. 5, 2015, 10:08 a.m. UTC
Hi Order,
I just notice your patch on the ML:
http://mailman.alsa-project.org/pipermail/alsa-devel/2015-October/098390.html
I didn't subscribe the ML and I'm not in CC so I cannot directly reply to you.

I think you should make a copy of memory for index_cache rather than
directly use the rt286_index_def if the index_cache is necessary.

Comments

Axel Lin Oct. 5, 2015, 10:16 a.m. UTC | #1
> -       rt286->index_cache = rt286_index_def;
>         rt286->index_cache_size = INDEX_CACHE_SIZE;
> +       rt286->index_cache = devm_kmalloc(&i2c->dev, INDEX_CACHE_SIZE,
> +                                         GFP_KERNEL);
Should be devm_kmalloc(&i2c->dev, sizeof(rt286_index_def), GFP_KERNEL);
diff mbox

Patch

diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 1fbdb4f..210ab415 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -37,7 +37,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;
@@ -1160,8 +1160,12 @@  static int rt286_i2c_probe(struct i2c_client *i2c,
 		return -ENODEV;
 	}
 
-	rt286->index_cache = rt286_index_def;
 	rt286->index_cache_size = INDEX_CACHE_SIZE;
+	rt286->index_cache = devm_kmalloc(&i2c->dev, INDEX_CACHE_SIZE,
+					  GFP_KERNEL);
+	if (!rt286->index_cache)
+		return -ENOMEM;
+
 	rt286->i2c = i2c;
 	i2c_set_clientdata(i2c, rt286);