Skip to content

Commit 0298f51

Browse files
Amadeusz Sławińskibroonie
authored andcommitted
ASoC: topology: Fix route memory corruption
It was reported that recent fix for memory corruption during topology load, causes corruption in other cases. Instead of being overeager with checking topology, assume that it is properly formatted and just duplicate strings. Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Closes: https://lore.kernel.org/linux-sound/171812236450.201359.3019210915105428447.b4-ty@kernel.org/T/#m8c4bd5abf453960fde6f826c4b7f84881da63e9d Suggested-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://lore.kernel.org/r/20240613090126.841189-1-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f3b198e commit 0298f51

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

sound/soc/soc-topology.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,21 +1052,15 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg,
10521052
break;
10531053
}
10541054

1055-
route->source = devm_kmemdup(tplg->dev, elem->source,
1056-
min(strlen(elem->source), maxlen),
1057-
GFP_KERNEL);
1058-
route->sink = devm_kmemdup(tplg->dev, elem->sink,
1059-
min(strlen(elem->sink), maxlen),
1060-
GFP_KERNEL);
1055+
route->source = devm_kstrdup(tplg->dev, elem->source, GFP_KERNEL);
1056+
route->sink = devm_kstrdup(tplg->dev, elem->sink, GFP_KERNEL);
10611057
if (!route->source || !route->sink) {
10621058
ret = -ENOMEM;
10631059
break;
10641060
}
10651061

10661062
if (strnlen(elem->control, maxlen) != 0) {
1067-
route->control = devm_kmemdup(tplg->dev, elem->control,
1068-
min(strlen(elem->control), maxlen),
1069-
GFP_KERNEL);
1063+
route->control = devm_kstrdup(tplg->dev, elem->control, GFP_KERNEL);
10701064
if (!route->control) {
10711065
ret = -ENOMEM;
10721066
break;

0 commit comments

Comments
 (0)