ASoC: SOF: topology: Fix logic for copying tuples
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Fri, 12 May 2023 11:46:30 +0000 (14:46 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 15 May 2023 01:21:15 +0000 (10:21 +0900)
Topology could have more instances of the tokens being searched for than
the number of sets that need to be copied. Stop copying token after the
limit of number of token instances has been reached. This worked before
only by chance as we had allocated more size for the tuples array than
the number of actual tokens being parsed.

Fixes: 7006d20e5e9d ("ASoC: SOF: Introduce IPC3 ops")
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
Link: https://lore.kernel.org/r/20230512114630.24439-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org
sound/soc/sof/topology.c

index d3d536b0a8f54d8516d360e0c0b80f7cc8fcc022..b805665705128d6f2d73cc659a507a19d3a406ef 100644 (file)
@@ -586,6 +586,10 @@ static int sof_copy_tuples(struct snd_sof_dev *sdev, struct snd_soc_tplg_vendor_
                                if (*num_copied_tuples == tuples_size)
                                        return 0;
                        }
+
+                       /* stop when we've found the required token instances */
+                       if (found == num_tokens * token_instance_num)
+                               return 0;
                }
 
                /* next array */