Skip to contentSkip to conversation

ASoC: core: Don't set "(null)" as a driver name

PATCH Superseded Jarkko Nikula 2 participants 3 messages May 20, 2011

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: core: Don't set "(null)" as a driver name

Commit 22de71b ("ASoC: core - allow ASoC more flexible machine name") writes "(null)" to driver name string in struct snd_card if card->driver_name is NULL. This causes segmentation faults with some user space ALSA utilities like aplay and arecord.

Fix this by using null terminated string instead as this was the case before.

---
 sound/soc/soc-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/soc-core.c +1 -1
index 5968745..ab05f42 100644
@@ -1930,7 +1930,7 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 	snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
 		 "%s", card->long_name ? card->long_name : card->name);
 	snprintf(card->snd_card->driver, sizeof(card->snd_card->driver),
-		 "%s", card->driver_name);
+		 "%s", card->driver_name ? card->driver_name : "");
 
 	if (card->late_probe) {
 		ret = card->late_probe(card);
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 17 lines · Jarkko Nikula

Commit 22de71b ("ASoC: core - allow ASoC more flexible machine name") writes "(null)" to driver name string in struct snd_card if card->driver_name is NULL. This causes segmentation faults with some user space ALSA utilities like aplay and arecord.

Fix this by using null terminated string instead as this was the case before.

---
 sound/soc/soc-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/soc-core.c +0 -0
index 5968745..ab05f42 100644

sound/soc/soc-core.c static void snd_soc_instantiate_card(struct snd_soc_card *card) · line 1936

Quoted 8 lines
sound/soc/soc-core.c +1 -1
@@ -1930,7 +1930,7 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 	snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
 		 "%s", card->long_name ? card->long_name : card->name);
 	snprintf(card->snd_card->driver, sizeof(card->snd_card->driver),
-		 "%s", card->driver_name);
+		 "%s", card->driver_name ? card->driver_name : "");
 
 	if (card->late_probe) {
 		ret = card->late_probe(card);

This looks good but we may want to make the default driver name (if no driver name is specified) to be the card->name instead of " " and should return an error if card->name is NULL.

Liam

#2 lore raw
Quoted 2 lines · On Fri, 20 May 2011 13:32:31 +0100 Liam Girdwood <[email protected]> wrote:

This looks good but we may want to make the default driver name (if no driver name is specified) to be the card->name instead of " " and should return an error if card->name is NULL.

Sounds better and card->name is already tested in
snd_soc_register_card. I'll update the patch.

Signature · 1 line
Jarkko