ASoC: Don't set invalid name string to snd_card->driver field
authorTakashi Iwai <tiwai@suse.de>
Tue, 5 Jul 2011 07:25:59 +0000 (09:25 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 5 Jul 2011 12:39:27 +0000 (14:39 +0200)
The snd_card->driver field contains a driver name string, and in
general it shouldn't contain space or special letters.  The commit
2b39535b9e54888649923beaab443af212b6c0fd changed the string copy from
card->name, but the long name string may contain such letters, thus
it may still lead to a segfault.

A temporary fix is not to copy the long name string but just keep it
empty as the earlier version did.

Reported-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/soc/soc-core.c

index d75043ed7fc0551f66881675df110dede0d5ccf0..b194be09e74d623220e06e3addb5bb4bfcf9fb70 100644 (file)
@@ -1929,8 +1929,9 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
                 "%s", card->name);
        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 ? card->driver_name : card->name);
+       if (card->driver_name)
+               strlcpy(card->snd_card->driver, card->driver_name,
+                       sizeof(card->snd_card->driver));
 
        if (card->late_probe) {
                ret = card->late_probe(card);