[alsa-devel] [PATCH][ASoC V2] 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.
Signed-off-by: Timur Tabi timur@freescale.com --- sound/soc/soc-core.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7dc6d68..520469b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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:
On Mon, May 19, 2008 at 05:45:59PM -0500, Timur Tabi wrote:
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.
At Tue, 20 May 2008 12:31:30 +0100, Mark Brown wrote:
On Mon, May 19, 2008 at 05:45:59PM -0500, Timur Tabi wrote:
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
On Wed, May 21, 2008 at 12:36:40PM +0200, Takashi Iwai wrote:
Mark Brown wrote:
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.
At Wed, 21 May 2008 11:54:26 +0100, Mark Brown wrote:
On Wed, May 21, 2008 at 12:36:40PM +0200, Takashi Iwai wrote:
Mark Brown wrote:
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.
Fair enough. Thanks for clarification.
Takashi
participants (3)
-
Mark Brown
-
Takashi Iwai
-
Timur Tabi