Skip to content

Commit

Permalink
ASoC: SOF: topology: allocate string for tuples
Browse files Browse the repository at this point in the history
The existing code point tuples[*num_copied_tuples].value.s to elem->string
which works fine if there is only one topology is handled and all the
tuples are handled before the topology fw is released. However, we will
handle multiple topologies and the tuples may be used after the topology
fw is release. Ues devm_kasprintf to allocate the string for the tuples
to avoid invalid access.

Signed-off-by: Bard Liao <[email protected]>
  • Loading branch information
bardliao committed Nov 22, 2024
1 parent 5f650cf commit 9e958d6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,11 @@ static int sof_copy_tuples(struct snd_sof_dev *sdev, struct snd_soc_tplg_vendor_
continue;

tuples[*num_copied_tuples].token = tokens[j].token;
tuples[*num_copied_tuples].value.s = elem->string;
tuples[*num_copied_tuples].value.s =
devm_kasprintf(sdev->dev, GFP_KERNEL,
"%s", elem->string);
if (!tuples[*num_copied_tuples].value.s)
return -ENOMEM;
} else {
struct snd_soc_tplg_vendor_value_elem *elem;

Expand Down

0 comments on commit 9e958d6

Please sign in to comment.