diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 069f38fbf07b89f8295bd0a49232ae7b09116110..b9e24b56cb58b68ba346501cf4484602e303873b 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1151,13 +1151,19 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) return -EINVAL; - route.source = elem->source; - route.sink = elem->sink; + route.source = devm_kstrdup(tplg->dev, elem->source, GFP_KERNEL); + route.sink = devm_kstrdup(tplg->dev, elem->sink, GFP_KERNEL); + if (!route.source || !route.sink) + return -ENOMEM; + route.connected = NULL; /* set to NULL atm for tplg users */ - if (strnlen(elem->control, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == 0) + if (strnlen(elem->control, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == 0) { route.control = NULL; - else - route.control = elem->control; + } else { + route.control = devm_kstrdup(tplg->dev, elem->control, GFP_KERNEL); + if (!route.control) + return -ENOMEM; + } soc_tplg_add_route(tplg, &route);