Skip to content

Commit

Permalink
ASoC: topology: Check name strings of physical DAI links
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mengdong Lin authored and Mark Brown committed Nov 9, 2016
1 parent 6ff67cc commit dbab1cb
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions sound/soc/soc-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit dbab1cb

Please sign in to comment.