13 Jun
2024
13 Jun
'24
8:44 a.m.
On 13/06/2024 09:29, Péter Ujfalusi wrote:
route->sink = devm_kmemdup(tplg->dev, elem->sink,
min(strlen(elem->sink), SNDRV_CTL_ELEM_ID_NAME_MAXLEN),
Initially I did not see why this breaks, but then:
The strlen() function calculates the length of the string pointed to by s, excluding the terminating null byte ('\0').
Likely the fix is as simple as: min(strlen(elem->sink) + 1, SNDRV_CTL_ELEM_ID_NAME_MAXLEN)
or better yet: route->sink = devm_kasprintf(tplg->dev, GFP_KERNEL, "%s", elem->sink);
or even better: route->sink = devm_kstrdup(tplg->dev, elem->sink, GFP_KERNEL);
--
Péter