lkml.org 
[lkml]   [2017]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] ASoC: Add a sanity check before using dai driver name
Date
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>
---

sound/soc/soc-core.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 77e7e2a11af0..8ab9ee2b460a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -978,11 +978,13 @@ struct snd_soc_dai *snd_soc_find_dai(
if (dlc->name && strcmp(component->name, dlc->name))
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))
- continue;
-
- return dai;
+ if (!dlc->dai_name)
+ return dai;
+ if (!strcmp(dai->name, dlc->dai_name))
+ return dai;
+ if (dai->driver->name &&
+ !strcmp(dai->driver->name, dlc->dai_name))
+ return dai;
}
}

--
2.11.0

\
 
 \ /
  Last update: 2017-08-22 16:45    [W:0.062 / U:5.908 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site