Skip to content

Commit 0bede93

Browse files
committed
ASoC: SOF: topology: allocate string for tuples
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 <yung-chuan.liao@linux.intel.com>
1 parent 0d7b596 commit 0bede93

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

sound/soc/sof/topology.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,11 @@ static int sof_copy_tuples(struct snd_sof_dev *sdev, struct snd_soc_tplg_vendor_
571571
continue;
572572

573573
tuples[*num_copied_tuples].token = tokens[j].token;
574-
tuples[*num_copied_tuples].value.s = elem->string;
574+
tuples[*num_copied_tuples].value.s =
575+
devm_kasprintf(sdev->dev, GFP_KERNEL,
576+
"%s", elem->string);
577+
if (!tuples[*num_copied_tuples].value.s)
578+
return -ENOMEM;
575579
} else {
576580
struct snd_soc_tplg_vendor_value_elem *elem;
577581

0 commit comments

Comments
 (0)