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 <[email protected]> Closes: https://lore.kernel.org/linux-sound/[email protected]/T/#m8c4bd5abf453960fde6f826c4b7f84881da63e9d Suggested-by: Péter Ujfalusi <[email protected]> Signed-off-by: Amadeusz Sławiński <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent f3b198e commit 0298f51

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

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)