diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 23a5f9a52da0fddf8ea0b95d3910811893deee70..c65c92b073b283098f50a5edd3c13fa08127027c 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1258,15 +1258,24 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, break; } - routes[i]->source = elem->source; - routes[i]->sink = elem->sink; + routes[i]->source = devm_kstrdup(tplg->dev, elem->source, GFP_KERNEL); + routes[i]->sink = devm_kstrdup(tplg->dev, elem->sink, GFP_KERNEL); + if (!routes[i]->source || !routes[i]->sink) { + ret = -ENOMEM; + break; + } /* set to NULL atm for tplg users */ routes[i]->connected = NULL; - if (strnlen(elem->control, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == 0) + if (strnlen(elem->control, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == 0) { routes[i]->control = NULL; - else - routes[i]->control = elem->control; + } else { + routes[i]->control = devm_kstrdup(tplg->dev, elem->control, GFP_KERNEL); + if (!routes[i]->control) { + ret = -ENOMEM; + break; + } + } /* add route dobj to dobj_list */ routes[i]->dobj.type = SND_SOC_DOBJ_GRAPH;