Skip to contentSkip to conversation

ASoC: fill in snd_soc_pcm_runtime.card before calling snd_soc_dai_link.init()

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

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

PATCH 1/1 ASoC: fill in snd_soc_pcm_runtime.card before calling snd_soc_dai_link.init()

The .card member of the snd_soc_pcm_runtime structure pointed to by the snd_soc_dai_link.init() argument used to be initialized before the function being called. This has changed, probably unintentionally, after recent refactorings. Since the function implementations are free to make use of this pointer, move its assignment back before the function is called to avoid NULL pointer dereferences.

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

---
Jarkko,
I'm not sure if this change won't break anything in your dailess related code path, please verify.

Thanks,
Janusz

 sound/soc/soc-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-core.c renamed from sound/soc/soc-core.c.orig +1 -1
@@ -1449,6 +1449,7 @@ static int soc_post_component_init(struc
 		rtd = &card->rtd_aux[num];
 		name = aux_dev->name;
 	}
+	rtd->card = card;
 
 	/* machine controls, routes and widgets are not prefixed */
 	temp = codec->name_prefix;
@@ -1471,7 +1472,6 @@ static int soc_post_component_init(struc
 
 	/* register the rtd device */
 	rtd->codec = codec;
-	rtd->card = card;
 	rtd->dev.parent = card->dev;
 	rtd->dev.release = rtd_release;
 	rtd->dev.init_name = name;
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Janusz Krzysztofik

The .card member of the snd_soc_pcm_runtime structure pointed to by the snd_soc_dai_link.init() argument used to be initialized before the function being called. This has changed, probably unintentionally, after recent refactorings. Since the function implementations are free to make use of this pointer, move its assignment back before the function is called to avoid NULL pointer dereferences.

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

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
Acked-by on v1 1/1
#2 lore raw
In reply to Janusz Krzysztofik
Quoted 32 lines · On Wed, 2 Feb 2011 21:11:41 +0100 Janusz Krzysztofik <[email protected]>…

The .card member of the snd_soc_pcm_runtime structure pointed to by the snd_soc_dai_link.init() argument used to be initialized before the function being called. This has changed, probably unintentionally, after recent refactorings. Since the function implementations are free to make use of this pointer, move its assignment back before the function is called to avoid NULL pointer dereferences.

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

---
Jarkko,
I'm not sure if this change won't break anything in your dailess related code path, please verify.

Thanks,
Janusz

 sound/soc/soc-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-core.c renamed from sound/soc/soc-core.c.orig +1 -0
@@ -1449,6 +1449,7 @@ static int soc_post_component_init(struc
 		rtd = &card->rtd_aux[num];
 		name = aux_dev->name;
 	}
+	rtd->card = card;
 
 	/* machine controls, routes and widgets are not prefixed */
 	temp = codec->name_prefix;

sound/soc/soc-core.c static int soc_post_component_init(struc · line 1477

Quoted 7 lines
sound/soc/soc-core.c renamed from sound/soc/soc-core.c.orig +0 -1
@@ -1471,7 +1472,6 @@ static int soc_post_component_init(struc
 
 	/* register the rtd device */
 	rtd->codec = codec;
-	rtd->card = card;
 	rtd->dev.parent = card->dev;
 	rtd->dev.release = rtd_release;
 	rtd->dev.init_name = name;

Thanks for spotting this Janusz. This was unintentional change done by the commit 589c356. Yet another proof how important platform is the Amstrad Delta :-)

rtd->codec is ok since it is set in soc_bind_dai_link prior calling the snd_soc_dai_link.init and snd_soc_aux_dev.init doesn't need it. Would be nice to set other rtd fields also where the rtd->card is set but that's not as urgent change than this.