linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: soc-core: Fix null pointer dereference in soc_find_component
@ 2019-01-11  8:14 Rohit kumar
  2019-01-11 15:44 ` [alsa-devel] " Pierre-Louis Bossart
  2019-01-14 23:26 ` Mark Brown
  0 siblings, 2 replies; 25+ messages in thread
From: Rohit kumar @ 2019-01-11  8:14 UTC (permalink / raw)
  To: plai, bgoswami, asishb, lgirdwood, broonie, perex, tiwai,
	alsa-devel, linux-kernel, rohkumar, srinivas.kandagatla,
	vinod.koul
  Cc: Ajit Pandey, Rohit kumar

From: Ajit Pandey <ajitp@codeaurora.org>

soc_find_component() may lead to null pointer exception if both
arguments i.e of_node and name is NULL. Add NULL check before
calling soc_find_component(). Also fix some typos.

Fixes: 8780cf1142a5 ("ASoC: soc-core: defer card probe until all component is added to list")
Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ajit Pandey <ajitp@codeaurora.org>
Signed-off-by: Rohit kumar <rohitkr@codeaurora.org>
---
 sound/soc/soc-core.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 0934b36..df05fb8 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1131,11 +1131,13 @@ static int soc_init_dai_link(struct snd_soc_card *card,
 	}
 
 	/*
-	 * Defer card registartion if platform dai component is not added to
+	 * Defer card registration if platform dai component is not added to
 	 * component list.
 	 */
-	if (!soc_find_component(link->platform->of_node, link->platform->name))
-		return -EPROBE_DEFER;
+	if (link->platform->of_node || link->platform->name)
+		if (!soc_find_component(link->platform->of_node,
+					link->platform->name))
+			return -EPROBE_DEFER;
 
 	/*
 	 * CPU device may be specified by either name or OF node, but
@@ -1150,11 +1152,12 @@ static int soc_init_dai_link(struct snd_soc_card *card,
 	}
 
 	/*
-	 * Defer card registartion if cpu dai component is not added to
+	 * Defer card registration if cpu dai component is not added to
 	 * component list.
 	 */
-	if (!soc_find_component(link->cpu_of_node, link->cpu_name))
-		return -EPROBE_DEFER;
+	if (link->cpu_of_node || link->cpu_name)
+		if (!soc_find_component(link->cpu_of_node, link->cpu_name))
+			return -EPROBE_DEFER;
 
 	/*
 	 * At least one of CPU DAI name or CPU device name/node must be
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


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

end of thread, other threads:[~2019-01-25  1:33 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11  8:14 [PATCH] ASoC: soc-core: Fix null pointer dereference in soc_find_component Rohit kumar
2019-01-11 15:44 ` [alsa-devel] " Pierre-Louis Bossart
2019-01-11 21:49   ` Pierre-Louis Bossart
2019-01-12  6:07     ` Rohit kumar
2019-01-14 15:40       ` Liam Girdwood
2019-01-15  0:06     ` Mark Brown
2019-01-15  3:08       ` Pierre-Louis Bossart
2019-01-15 19:35       ` Pierre-Louis Bossart
2019-01-15 21:07         ` Mark Brown
2019-01-15 21:11         ` Matthias Reichl
2019-01-15 21:16           ` Pierre-Louis Bossart
2019-01-15 21:41             ` Mark Brown
2019-01-15 21:48               ` Matthias Reichl
2019-01-18 23:02             ` Pierre-Louis Bossart
     [not found]               ` <CAOReqxjhZAzOpr-bGcV6uxPsOEid--Ym2Y0YZMHkybgZSePvtQ@mail.gmail.com>
2019-01-19  1:15                 ` Curtis Malainey
2019-01-21 18:30                   ` Mark Brown
2019-01-22 20:11                   ` Pierre-Louis Bossart
2019-01-23  1:36                     ` Curtis Malainey
2019-01-23  2:01                       ` Pierre-Louis Bossart
2019-01-24 18:44                         ` Mark Brown
2019-01-24 19:07                           ` Pierre-Louis Bossart
2019-01-24 19:26                             ` Mark Brown
2019-01-25  1:32                               ` Curtis Malainey
2019-01-21 19:17               ` Mark Brown
2019-01-14 23:26 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).