Skip to contentSkip to conversation

ASoC: Amstrad Delta: fix NULL pointer dereference

PATCH In review Janusz Krzysztofik 2 participants 3 messages Feb 1, 2011 – Feb 2, 2011

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

PATCH 1/1 ASoC: Amstrad Delta: fix NULL pointer dereference

It looks like the .card member of the snd_soc_pcm_runtime structure pointed to by the snd_soc_dai_link.init() argument is no longer initialized before the function being called. As the Amstrad Delta sound card driver was making use of it for locating its snd_soc_card structure, this resulted in actual or potential NULL pointer dereferences.

Since the structure in question is local to the driver, its address can be referred directly instead of trying to derive it from the function argument. Fix it.

Created and tested against linux-2.6.38-rc2

---
Please consider queuing this patch for the current rc cycle.

 sound/soc/omap/ams-delta.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/omap/ams-delta.c renamed from sound/soc/omap/ams-delta.c.orig +3 -1
@@ -492,12 +492,14 @@ static void ams_delta_shutdown(struct sn
  * Card initialization
  */
 
+static struct snd_soc_card ams_delta_audio_card;
+
 static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_dapm_context *dapm = &codec->dapm;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_card *card = rtd->card;
+	struct snd_soc_card *card = &ams_delta_audio_card;
 	int ret;
 	/* Codec is ready, now add/activate board specific controls */
#1 lore raw
Quoted 6 lines · Janusz Krzysztofik

It looks like the .card member of the snd_soc_pcm_runtime structure pointed to by the snd_soc_dai_link.init() argument is no longer initialized before the function being called. As the Amstrad Delta sound card driver was making use of it for locating its snd_soc_card structure, this resulted in actual or potential NULL pointer dereferences.

Seems like it'd be better to fix this in the core - this is a reasonable thing to want to have set up and the use ams-delta makes of it seems perfectly sensible. Care to do a patch?

#2 lore raw

Dnia wtorek 01 luty 2011 o 22:33:01 Mark Brown napisał(a):

Quoted 11 lines · Janusz Krzysztofik
Quoted 6 lines

It looks like the .card member of the snd_soc_pcm_runtime structure pointed to by the snd_soc_dai_link.init() argument is no longer initialized before the function being called. As the Amstrad Delta sound card driver was making use of it for locating its snd_soc_card structure, this resulted in actual or potential NULL pointer dereferences.

Seems like it'd be better to fix this in the core - this is a reasonable thing to want to have set up and the use ams-delta makes of it seems perfectly sensible. Care to do a patch?

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