Skip to contentSkip to conversation

Fix null-pointer dereference in soc_create_pcm()

PATCH Applied Timur Tabi 3 participants 5 messages May 19, 2008 – May 21, 2008

Subsystems (2)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH v2 1/1 Fix null-pointer dereference in soc_create_pcm()

When soc_create_pcm() finds all four components it needs, it displays a status message. This message references the local variables 'codec_dai' and 'cpu_dai', but these variables are initialized only when the codec DAI and the cpu DAI are the last to be registered. This patch changes the code to use the stored values instead of the local variables.

---
 sound/soc/soc-core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/soc-core.c +2 -2
index 7dc6d68..520469b 100644
@@ -921,8 +921,8 @@ check:
 	}
 
 	pcm->private_free = platform->pcm_free;
-	printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,
-		cpu_dai->name);
+	printk(KERN_INFO "asoc: %s <-> %s mapping ok\n",
+		pcm_runtime->codec_dai->name, pcm_runtime->cpu_dai->name);
 	list_add(&pcm_runtime->list, &soc_card->pcm_list);
 	return 1;
 err:
Signature · 1 line
1.5.5
Applied
#1 lore raw
Quoted 5 lines · Timur Tabi

When soc_create_pcm() finds all four components it needs, it displays a status message. This message references the local variables 'codec_dai' and 'cpu_dai', but these variables are initialized only when the codec DAI and the cpu DAI are the last to be registered. This patch changes the code to use the stored values instead of the local variables.

Thanks, applied.

#2 lore raw

At Tue, 20 May 2008 12:31:30 +0100,

Quoted 9 lines · Mark Brown
Quoted 5 lines · Timur Tabi

When soc_create_pcm() finds all four components it needs, it displays a status message. This message references the local variables 'codec_dai' and 'cpu_dai', but these variables are initialized only when the codec DAI and the cpu DAI are the last to be registered. This patch changes the code to use the stored values instead of the local variables.

Thanks, applied.

This looks applicable to the upstream tree... Shouldn't it be fixed as well?

thanks,

Takashi

#3 lore raw
Quoted 7 lines · Takashi Iwai
Quoted 2 lines · Mark Brown
Quoted 2 lines

When soc_create_pcm() finds all four components it needs, it displays a status message. This message references the local variables 'codec_dai' and

This looks applicable to the upstream tree... Shouldn't it be fixed as well?

The error condition can't occur in ASoC v1 - it doesn't support the dynamic registration of machine components so the local codec and CPU DAI variables must always have been initialised if soc_new_pcm() succeeds. It's an issue for v2 because soc_create_pcm() can be called multiple times if the PCM is registered before all the components required to create it are registered - if that happens then only the last component to be added will have had the local variables initialised.

#4 lore raw

At Wed, 21 May 2008 11:54:26 +0100,

Quoted 10 lines · Mark Brown
Quoted 7 lines · Takashi Iwai
Quoted 2 lines · Mark Brown
Quoted 2 lines

When soc_create_pcm() finds all four components it needs, it displays a status message. This message references the local variables 'codec_dai' and

This looks applicable to the upstream tree... Shouldn't it be fixed as well?

Quoted 8 lines

The error condition can't occur in ASoC v1 - it doesn't support the dynamic registration of machine components so the local codec and CPU DAI variables must always have been initialised if soc_new_pcm() succeeds. It's an issue for v2 because soc_create_pcm() can be called multiple times if the PCM is registered before all the components required to create it are registered - if that happens then only the last component to be added will have had the local variables initialised.

Fair enough. Thanks for clarification.

Takashi