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
- Follow-Ups:
- Re: [PATCH 1/4] ASoC: topology: Fix references to freed memory
- From: Amadeusz Sławiński
- Re: [PATCH 1/4] ASoC: topology: Fix references to freed memory
- References:
- [PATCH 0/4] ASoC: topology: Fix route memory corruption
- From: Amadeusz Sławiński
- [PATCH 1/4] ASoC: topology: Fix references to freed memory
- From: Amadeusz Sławiński
- Re: [PATCH 1/4] ASoC: topology: Fix references to freed memory
- From: Pierre-Louis Bossart
- Re: [PATCH 1/4] ASoC: topology: Fix references to freed memory
- From: Péter Ujfalusi
- Re: [PATCH 1/4] ASoC: topology: Fix references to freed memory
- From: Péter Ujfalusi
- [PATCH 0/4] ASoC: topology: Fix route memory corruption
- Prev by Date: Re: [PATCH v3] dt-bindings: sound: Convert max98088 to dtschema
- Next by Date: Re: [PATCH 1/4] ASoC: topology: Fix references to freed memory
- Previous by thread: Re: [PATCH 1/4] ASoC: topology: Fix references to freed memory
- Next by thread: Re: [PATCH 1/4] ASoC: topology: Fix references to freed memory
- Index(es):