public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Add a sanity check before using dai driver name
@ 2017-08-22 14:45 Jeffy Chen
  2017-08-22 16:17 ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Jeffy Chen @ 2017-08-22 14:45 UTC (permalink / raw)
  To: linux-kernel, broonie
  Cc: tiwai, dolinux.peng, Jeffy Chen, Jaroslav Kysela, alsa-devel,
	Takashi Iwai, Liam Girdwood

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-08-24 10:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22 14:45 [PATCH] ASoC: Add a sanity check before using dai driver name Jeffy Chen
2017-08-22 16:17 ` Mark Brown
2017-08-22 23:42   ` jeffy
2017-08-23 11:06     ` Mark Brown
2017-08-24  3:29       ` jeffy
2017-08-24 10:18         ` Mark Brown
2017-08-24 10:44           ` jeffy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox