ASoC: Add a sanity check before using dai driver name
authorJeffy Chen <jeffy.chen@rock-chips.com>
Thu, 24 Aug 2017 04:40:17 +0000 (12:40 +0800)
committerMark Brown <broonie@kernel.org>
Fri, 25 Aug 2017 13:49:44 +0000 (14:49 +0100)
The dai driver's name is allowed to be NULL. So add a sanity check for
that.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reported-by: Donglin Peng <dolinux.peng@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-core.c

index 6fab0ff..74c1706 100644 (file)
@@ -1029,7 +1029,8 @@ struct snd_soc_dai *snd_soc_find_dai(
                        continue;
                list_for_each_entry(dai, &component->dai_list, list) {
                        if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
-                           && strcmp(dai->driver->name, dlc->dai_name))
+                           && (!dai->driver->name
+                               || strcmp(dai->driver->name, dlc->dai_name)))
                                continue;
 
                        return dai;