[PATCH] ASoC: Add a sanity check before using dai driver name

From: Jeffy Chen
Date: Thu Aug 24 2017 - 00:40:17 EST


The dai driver's name is allowed to be NULL. So add a sanity check for
that.

Signed-off-by: Jeffy Chen <jeffy.chen@xxxxxxxxxxxxxx>
Reported-by: Donglin Peng <dolinux.peng@xxxxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
---
sound/soc/soc-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6fab0ff213ef..74c17068bb11 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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;
--
2.13.2