Skip to content

Commit fd660b1

Browse files
Amadeusz Sławińskibroonie
authored andcommitted
ASoC: Intel: avs: Fix route override
Instead of overriding existing memory strings that may be too short, just allocate needed memory and point the route at it. Reported-by: Jason Montleon <jmontleo@redhat.com> Link: thesofproject/avs-topology-xml#22 (comment) Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://lore.kernel.org/r/20240603102818.36165-3-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 97ab304 commit fd660b1

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

sound/soc/intel/avs/topology.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,8 +1545,8 @@ static int avs_route_load(struct snd_soc_component *comp, int index,
15451545
{
15461546
struct snd_soc_acpi_mach *mach = dev_get_platdata(comp->card->dev);
15471547
size_t len = SNDRV_CTL_ELEM_ID_NAME_MAXLEN;
1548-
char buf[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
15491548
int ssp_port, tdm_slot;
1549+
char *buf;
15501550

15511551
/* See parse_link_formatted_string() for dynamic naming when(s). */
15521552
if (!avs_mach_singular_ssp(mach))
@@ -1557,13 +1557,24 @@ static int avs_route_load(struct snd_soc_component *comp, int index,
15571557
return 0;
15581558
tdm_slot = avs_mach_ssp_tdm(mach, ssp_port);
15591559

1560+
buf = devm_kzalloc(comp->card->dev, len, GFP_KERNEL);
1561+
if (!buf)
1562+
return -ENOMEM;
15601563
avs_ssp_sprint(buf, len, route->source, ssp_port, tdm_slot);
1561-
strscpy((char *)route->source, buf, len);
1564+
route->source = buf;
1565+
1566+
buf = devm_kzalloc(comp->card->dev, len, GFP_KERNEL);
1567+
if (!buf)
1568+
return -ENOMEM;
15621569
avs_ssp_sprint(buf, len, route->sink, ssp_port, tdm_slot);
1563-
strscpy((char *)route->sink, buf, len);
1570+
route->sink = buf;
1571+
15641572
if (route->control) {
1573+
buf = devm_kzalloc(comp->card->dev, len, GFP_KERNEL);
1574+
if (!buf)
1575+
return -ENOMEM;
15651576
avs_ssp_sprint(buf, len, route->control, ssp_port, tdm_slot);
1566-
strscpy((char *)route->control, buf, len);
1577+
route->control = buf;
15671578
}
15681579

15691580
return 0;

0 commit comments

Comments
 (0)