Skip to contentSkip to conversation

ASoC: CX20442: fix NULL pointer dereference

PATCH Applied Janusz Krzysztofik 4 participants 7 messages Feb 1, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: CX20442: fix NULL pointer dereference

The CX20442 codec driver never provided the snd_soc_codec_driver's .reg_cache_default member. With the latest ASoC framework changes, it seems to be referred unconditionally, resulting in a NULL pointer dereference if missing. Provide it.

Created and tested on Amstrad Delta against linux-2.6.38-rc2

---
NOTE:
I'm not sure if the value choosen is Amstrad Delta specific or not.

 sound/soc/codecs/cx20442.c |    3 +++
 1 file changed, 3 insertions(+)
sound/soc/codecs/cx20442.c renamed from sound/soc/codecs/cx20442.c.orig +3 -0
@@ -367,9 +367,12 @@ static int cx20442_codec_remove(struct s
 	return 0;
 }
 
+static const u8 cx20442_reg = CX20442_TELOUT | CX20442_MIC;
+
 static struct snd_soc_codec_driver cx20442_codec_dev = {
 	.probe = 	cx20442_codec_probe,
 	.remove = 	cx20442_codec_remove,
+	.reg_cache_default = &cx20442_reg,
 	.reg_cache_size = 1,
 	.reg_word_size = sizeof(u8),
 	.read = cx20442_read_reg_cache,
#1 lore raw
Quoted 11 lines · On 01 February 2011 13:01:17 Janusz Krzysztofik wrote:

The CX20442 codec driver never provided the snd_soc_codec_driver's .reg_cache_default member. With the latest ASoC framework changes, it seems to be referred unconditionally, resulting in a NULL pointer dereference if missing. Provide it.

Created and tested on Amstrad Delta against linux-2.6.38-rc2

---
NOTE:
I'm not sure if the value choosen is Amstrad Delta specific or not.

I forgot to mention: please consider queuing this patch for the current rc cycle.

Thanks,
Janusz

Quoted 19 lines
 sound/soc/codecs/cx20442.c |    3 +++
 1 file changed, 3 insertions(+)
sound/soc/codecs/cx20442.c renamed from sound/soc/codecs/cx20442.c.orig +3 -0
@@ -367,9 +367,12 @@ static int cx20442_codec_remove(struct s
 	return 0;
 }
 
+static const u8 cx20442_reg = CX20442_TELOUT | CX20442_MIC;
+
 static struct snd_soc_codec_driver cx20442_codec_dev = {
 	.probe = 	cx20442_codec_probe,
 	.remove = 	cx20442_codec_remove,
+	.reg_cache_default = &cx20442_reg,
 	.reg_cache_size = 1,
 	.reg_word_size = sizeof(u8),
 	.read = cx20442_read_reg_cache,
#2 lore raw
In reply to Janusz Krzysztofik
Quoted 4 lines · Janusz Krzysztofik

The CX20442 codec driver never provided the snd_soc_codec_driver's .reg_cache_default member. With the latest ASoC framework changes, it seems to be referred unconditionally, resulting in a NULL pointer dereference if missing. Provide it.

This shouldn't happen with the latest ASoC as there is support for NULL default caches. In particular the following code should be taking care of the NULL pointer dereference

if (codec_drv->reg_cache_default) {
	codec->reg_def_copy = kmemdup(...);
	if (!codec->reg_def_copy) {
		ret = -ENOMEM;
		goto fail;
	}
}

If this is not what soc-core looks like for you please pull broonie's latest development tree.

Thanks,
Dimitris

#3 lore raw

Dnia wtorek 01 luty 2011 o 13:07:50 Dimitris Papastamos napisał(a):

Quoted 18 lines · Janusz Krzysztofik
Quoted 4 lines

The CX20442 codec driver never provided the snd_soc_codec_driver's .reg_cache_default member. With the latest ASoC framework changes, it seems to be referred unconditionally, resulting in a NULL pointer dereference if missing. Provide it.

This shouldn't happen with the latest ASoC as there is support for NULL default caches. In particular the following code should be taking care of the NULL pointer dereference

if (codec_drv->reg_cache_default) {
	codec->reg_def_copy = kmemdup(...);
	if (!codec->reg_def_copy) {
		ret = -ENOMEM;
		goto fail;
	}
}
Quoted 2 lines

If this is not what soc-core looks like for you please pull broonie's latest development tree.

Fine, but your fix is sitting in Mark's 'for-2.6.39' branch, while the CX20442 codec driver (perhaps not only this one) has been broken for 2.6.38.

Mark, are you going to cherry-pick Dimitris' fix to your 'for-2.6.38'?

Thanks,
Janusz
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw
Quoted 1 line · Janusz Krzysztofik

Mark, are you going to cherry-pick Dimitris' fix to your 'for-2.6.38'?

No.

Acked-by on v1 1/1
#5 lore raw
In reply to Janusz Krzysztofik
Quoted 30 lines · Janusz Krzysztofik

The CX20442 codec driver never provided the snd_soc_codec_driver's .reg_cache_default member. With the latest ASoC framework changes, it seems to be referred unconditionally, resulting in a NULL pointer dereference if missing. Provide it.

Created and tested on Amstrad Delta against linux-2.6.38-rc2

---
NOTE:
I'm not sure if the value choosen is Amstrad Delta specific or not.

 sound/soc/codecs/cx20442.c |    3 +++
 1 file changed, 3 insertions(+)
sound/soc/codecs/cx20442.c renamed from sound/soc/codecs/cx20442.c.orig +3 -0
@@ -367,9 +367,12 @@ static int cx20442_codec_remove(struct s
 	return 0;
 }
 
+static const u8 cx20442_reg = CX20442_TELOUT | CX20442_MIC;
+
 static struct snd_soc_codec_driver cx20442_codec_dev = {
 	.probe = 	cx20442_codec_probe,
 	.remove = 	cx20442_codec_remove,
+	.reg_cache_default = &cx20442_reg,
 	.reg_cache_size = 1,
 	.reg_word_size = sizeof(u8),
 	.read = cx20442_read_reg_cache,
Quoted 1 line

_______________________________________________

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
Applied
#6 lore raw
In reply to Janusz Krzysztofik
Quoted 4 lines · Janusz Krzysztofik

The CX20442 codec driver never provided the snd_soc_codec_driver's .reg_cache_default member. With the latest ASoC framework changes, it seems to be referred unconditionally, resulting in a NULL pointer dereference if missing. Provide it.

Applied, thanks.