Skip to contentSkip to conversation

ASoC: simple-card: Add cpu_dai and codec_dai names NULL check

PATCH Applied Xiubo Li 2 participants 4 messages Dec 20, 2013 – Dec 31, 2013

Subsystems (3)
lore
Share & tools
lore

Xiubo Li

author
#0 lore raw

PATCH 1/1 ASoC: simple-card: Add cpu_dai and codec_dai names NULL check

The name of cpu DAI maybe omitted, and then strlen() will lead kernel panic.

---
 sound/soc/generic/simple-card.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/generic/simple-card.c +3 -0
index 3d190d0..1d87db8 100644
@@ -142,6 +142,9 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (ret < 0)
 		return ret;
 
+	if (!info->cpu_dai.name || !info->codec_dai.name)
+		return -EINVAL;
+
 	/* card name is created from CPU/CODEC dai name */
 	name = devm_kzalloc(dev,
 			    strlen(info->cpu_dai.name)   +
Signature · 1 line
1.8.4
author
#1 lore raw

PATCH 1/1 ASoC: soc-core: Fix the DAI name getting.

Quoted 1 line

From "ASoC: make snd_soc_dai_link more symmetrical", can we see that

the name of CPU DAI maybe omitted. If the DAI name is omitted, try to use the component name instead.

---
 sound/soc/soc-core.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/soc-core.c +7 -3
index a66783e..be88df5 100644
@@ -4617,10 +4617,14 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,
 
 			if (id < 0 || id >= pos->num_dai) {
 				ret = -EINVAL;
-			} else {
-				*dai_name = pos->dai_drv[id].name;
-				ret = 0;
+				break;
 			}
+
+			ret = 0;
+
+			*dai_name = pos->dai_drv[id].name;
+			if (!*dai_name)
+				*dai_name = pos->name;
 		}
 
 		break;
Signature · 1 line
1.8.4
maintainer Applied
#2 lore raw

Re: [PATCH] ASoC: soc-core: Fix the DAI name getting.

Quoted 3 lines · Xiubo Li

From "ASoC: make snd_soc_dai_link more symmetrical", can we see that the name of CPU DAI maybe omitted. If the DAI name is omitted, try to use the component name instead.

Applied, thanks.

maintainer Applied
#3 lore raw
In reply to Xiubo Li
Quoted 2 lines · Xiubo Li

The name of cpu DAI maybe omitted, and then strlen() will lead kernel panic.

Applied, thanks.