summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMengdong Lin <mengdong.lin@linux.intel.com>2016-11-05 08:42:14 +0800
committerMark Brown <broonie@kernel.org>2016-11-09 14:46:04 +0000
commitdbab1cb88e84813254091d0d02ab83d9929e6a27 (patch)
treef2f9a99c720511f0d17dacd73537e462d3400b41 /sound
parent6ff67ccafdf4c782489de1ccc47e1ec8d8480b63 (diff)
downloadlinux-stable-dbab1cb88e84813254091d0d02ab83d9929e6a27.tar.gz
linux-stable-dbab1cb88e84813254091d0d02ab83d9929e6a27.tar.bz2
linux-stable-dbab1cb88e84813254091d0d02ab83d9929e6a27.zip
ASoC: topology: Check name strings of physical DAI links
Check if the name strings are properly terminated, and only use valid name strings to find existing physical DAI links to configure. Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-topology.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 8772fd994e82..4dfdc656cce6 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1994,10 +1994,24 @@ static int soc_tplg_link_config(struct soc_tplg *tplg,
{
struct snd_soc_dai_link *link;
const char *name, *stream_name;
+ size_t len;
int ret;
- name = strlen(cfg->name) ? cfg->name : NULL;
- stream_name = strlen(cfg->stream_name) ? cfg->stream_name : NULL;
+ len = strnlen(cfg->name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+ if (len == SNDRV_CTL_ELEM_ID_NAME_MAXLEN)
+ return -EINVAL;
+ else if (len)
+ name = cfg->name;
+ else
+ name = NULL;
+
+ len = strnlen(cfg->stream_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+ if (len == SNDRV_CTL_ELEM_ID_NAME_MAXLEN)
+ return -EINVAL;
+ else if (len)
+ stream_name = cfg->stream_name;
+ else
+ stream_name = NULL;
link = snd_soc_find_dai_link(tplg->comp->card, cfg->id,
name, stream_name);