All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: CX20442: fix NULL pointer dereference
@ 2011-02-01 12:01 Janusz Krzysztofik
  2011-02-01 12:07 ` Janusz Krzysztofik
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Janusz Krzysztofik @ 2011-02-01 12:01 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Liam Girdwood

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

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
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(+)

--- git/sound/soc/codecs/cx20442.c.orig	2011-01-31 20:09:18.000000000 +0100
+++ git/sound/soc/codecs/cx20442.c	2011-01-31 20:16:20.000000000 +0100
@@ -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,

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: CX20442: fix NULL pointer dereference
  2011-02-01 12:01 [PATCH] ASoC: CX20442: fix NULL pointer dereference Janusz Krzysztofik
@ 2011-02-01 12:07 ` Janusz Krzysztofik
  2011-02-01 12:07 ` Dimitris Papastamos
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Janusz Krzysztofik @ 2011-02-01 12:07 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Liam Girdwood

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
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> ---
> 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

> 
>  sound/soc/codecs/cx20442.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> --- git/sound/soc/codecs/cx20442.c.orig	2011-01-31 20:09:18.000000000 +0100
> +++ git/sound/soc/codecs/cx20442.c	2011-01-31 20:16:20.000000000 +0100
> @@ -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,

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: CX20442: fix NULL pointer dereference
  2011-02-01 12:01 [PATCH] ASoC: CX20442: fix NULL pointer dereference Janusz Krzysztofik
  2011-02-01 12:07 ` Janusz Krzysztofik
@ 2011-02-01 12:07 ` Dimitris Papastamos
  2011-02-01 13:18   ` Janusz Krzysztofik
  2011-02-01 14:30 ` Liam Girdwood
  2011-02-01 14:31 ` Mark Brown
  3 siblings, 1 reply; 7+ messages in thread
From: Dimitris Papastamos @ 2011-02-01 12:07 UTC (permalink / raw)
  To: Janusz Krzysztofik; +Cc: alsa-devel, Mark Brown, Liam Girdwood

On Tue, 2011-02-01 at 13:01 +0100, 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.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: CX20442: fix NULL pointer dereference
  2011-02-01 12:07 ` Dimitris Papastamos
@ 2011-02-01 13:18   ` Janusz Krzysztofik
  2011-02-01 13:19     ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Janusz Krzysztofik @ 2011-02-01 13:18 UTC (permalink / raw)
  To: Dimitris Papastamos; +Cc: alsa-devel, Mark Brown, Liam Girdwood

Dnia wtorek 01 luty 2011 o 13:07:50 Dimitris Papastamos napisał(a):
> On Tue, 2011-02-01 at 13:01 +0100, 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.
> 
> 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.

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
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: CX20442: fix NULL pointer dereference
  2011-02-01 13:18   ` Janusz Krzysztofik
@ 2011-02-01 13:19     ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2011-02-01 13:19 UTC (permalink / raw)
  To: Janusz Krzysztofik; +Cc: Dimitris Papastamos, alsa-devel, Liam Girdwood

On Tue, Feb 01, 2011 at 02:18:02PM +0100, Janusz Krzysztofik wrote:

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

No.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: CX20442: fix NULL pointer dereference
  2011-02-01 12:01 [PATCH] ASoC: CX20442: fix NULL pointer dereference Janusz Krzysztofik
  2011-02-01 12:07 ` Janusz Krzysztofik
  2011-02-01 12:07 ` Dimitris Papastamos
@ 2011-02-01 14:30 ` Liam Girdwood
  2011-02-01 14:31 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Liam Girdwood @ 2011-02-01 14:30 UTC (permalink / raw)
  To: Janusz Krzysztofik; +Cc: alsa-devel, Mark Brown

On Tue, 2011-02-01 at 13:01 +0100, 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
> 
> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
> ---
> 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(+)
> 
> --- git/sound/soc/codecs/cx20442.c.orig	2011-01-31 20:09:18.000000000 +0100
> +++ git/sound/soc/codecs/cx20442.c	2011-01-31 20:16:20.000000000 +0100
> @@ -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,
> _______________________________________________

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: CX20442: fix NULL pointer dereference
  2011-02-01 12:01 [PATCH] ASoC: CX20442: fix NULL pointer dereference Janusz Krzysztofik
                   ` (2 preceding siblings ...)
  2011-02-01 14:30 ` Liam Girdwood
@ 2011-02-01 14:31 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2011-02-01 14:31 UTC (permalink / raw)
  To: Janusz Krzysztofik; +Cc: alsa-devel, Liam Girdwood

On Tue, Feb 01, 2011 at 01:01:17PM +0100, 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.

Applied, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-01 14:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01 12:01 [PATCH] ASoC: CX20442: fix NULL pointer dereference Janusz Krzysztofik
2011-02-01 12:07 ` Janusz Krzysztofik
2011-02-01 12:07 ` Dimitris Papastamos
2011-02-01 13:18   ` Janusz Krzysztofik
2011-02-01 13:19     ` Mark Brown
2011-02-01 14:30 ` Liam Girdwood
2011-02-01 14:31 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.