From 17e4aa6ad715fddbc2879a8c71af4b0205872b93 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 20 Apr 2020 17:10:36 +0300 Subject: [PATCH 1/4] Testbench: Add definition for token SOF_TKN_COMP_CORE_ID This patch adds the token into header file tokens.h. It is used for topology parsing for testbench and fuzzer. The same token has been already defined in topology m4 macros. Signed-off-by: Seppo Ingalsuo --- src/include/kernel/tokens.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/kernel/tokens.h b/src/include/kernel/tokens.h index e09178d722ac..9290fa5e2a0a 100644 --- a/src/include/kernel/tokens.h +++ b/src/include/kernel/tokens.h @@ -71,6 +71,7 @@ /* Token retired with ABI 3.2, do not use for new capabilities * #define SOF_TKN_COMP_PRELOAD_COUNT 403 */ +#define SOF_TKN_COMP_CORE_ID 404 /* SSP */ #define SOF_TKN_INTEL_SSP_CLKS_CONTROL 500 From fbafcd7d32a2bcc0341c66f5ff8d0739c033c9b2 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 20 Apr 2020 17:19:40 +0300 Subject: [PATCH 2/4] Testbench: Parse all buffer widget vendor arrays In some topologies there is a component tokens array after buffer tokens array for buffer widget. Since the earlier code version was able to handle only single array and did not skip the remaining it caused the remaining topology parsing to go out of sync and fail. This patch changes the vendor array parsing to be similar as for PCM widget that already had capability to handle several arrays. The core id is retrieved if present in topology and passed via IPC. Signed-off-by: Seppo Ingalsuo --- .../include/tplg_parser/topology.h | 5 ++ tools/tplg_parser/tplg_parser.c | 50 ++++++++++++++----- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/tools/tplg_parser/include/tplg_parser/topology.h b/tools/tplg_parser/include/tplg_parser/topology.h index d04ffb25320f..d98acdb71496 100644 --- a/tools/tplg_parser/include/tplg_parser/topology.h +++ b/tools/tplg_parser/include/tplg_parser/topology.h @@ -80,6 +80,11 @@ static const struct sof_topology_token buffer_tokens[] = { offsetof(struct sof_ipc_buffer, caps), 0}, }; +static const struct sof_topology_token buffer_comp_tokens[] = { + {SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_uint32_t, + offsetof(struct sof_ipc_comp, core), 0}, +}; + /* scheduling */ static const struct sof_topology_token sched_tokens[] = { {SOF_TKN_SCHED_PERIOD, SND_SOC_TPLG_TUPLE_TYPE_WORD, diff --git a/tools/tplg_parser/tplg_parser.c b/tools/tplg_parser/tplg_parser.c index bc2b6c96df02..24e685bdd0b0 100644 --- a/tools/tplg_parser/tplg_parser.c +++ b/tools/tplg_parser/tplg_parser.c @@ -117,6 +117,8 @@ int tplg_load_buffer(int comp_id, int pipeline_id, int size, struct sof_ipc_buffer *buffer, FILE *file) { struct snd_soc_tplg_vendor_array *array; + size_t read_size; + size_t parsed_size = 0; int ret = 0; /* configure buffer */ @@ -131,22 +133,46 @@ int tplg_load_buffer(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: malloc fail during load_buffer\n"); - free(array); return -EINVAL; } - ret = fread(array, sizeof(struct snd_soc_tplg_vendor_array), 1, file); - if (ret != 1) { - fprintf(stderr, "error: fread fail during load_buffer\n"); - free(array); - return -EINVAL; - } + /* read vendor tokens */ + while (parsed_size < size) { + read_size = sizeof(struct snd_soc_tplg_vendor_array); + ret = fread(array, read_size, 1, file); + if (ret != 1) { + fprintf(stderr, + "error: fread fail during load_buffer\n"); + free(array); + return -EINVAL; + } + + tplg_read_array(array, file); - tplg_read_array(array, file); + /* parse buffer comp tokens */ + ret = sof_parse_tokens(&buffer->comp, buffer_comp_tokens, + ARRAY_SIZE(buffer_comp_tokens), array, + array->size); + if (ret) { + fprintf(stderr, "error: parse buffer comp tokens %d\n", + size); + free(array); + return -EINVAL; + } - /* parse buffer tokens */ - ret = sof_parse_tokens(buffer, buffer_tokens, - ARRAY_SIZE(buffer_tokens), array, size); + /* parse buffer tokens */ + ret = sof_parse_tokens(buffer, buffer_tokens, + ARRAY_SIZE(buffer_tokens), array, + array->size); + if (ret) { + fprintf(stderr, "error: parse buffer tokens %d\n", + size); + free(array); + return -EINVAL; + } + + parsed_size += array->size; + } free(array); return 0; @@ -1144,7 +1170,7 @@ int sof_parse_tokens(void *object, const struct sof_topology_token *tokens, priv_size -= asize; if (priv_size < 0) { - fprintf(stderr, "error: invalid array size 0x%x\n", + fprintf(stderr, "error: invalid priv size 0x%x\n", asize); return -EINVAL; } From 2ae41b541f5503e8011f6eb1972dbc310e2bc3a2 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 22 Apr 2020 11:32:08 +0300 Subject: [PATCH 3/4] Testbench: Return -errno values from malloc and fseek functions This patch replaces the manually set error codes with errno that is set to exact fail reason like ENOMEM etc. by these functions. The missing return code checks for fseek() calls are added. Include of header errno.h is added to topology.c. The order of include statements is fixed. Signed-off-by: Seppo Ingalsuo --- tools/testbench/topology.c | 35 +++++++--- tools/tplg_parser/tplg_parser.c | 117 ++++++++++++++++++++++---------- 2 files changed, 106 insertions(+), 46 deletions(-) diff --git a/tools/testbench/topology.c b/tools/testbench/topology.c index a647b99aee21..b216e6ab98f6 100644 --- a/tools/testbench/topology.c +++ b/tools/testbench/topology.c @@ -7,16 +7,17 @@ /* Topology loader to set up components and pipeline */ +#include +#include #include -#include -#include #include +#include #include -#include #include -#include "testbench/file.h" +#include #include #include "testbench/common_test.h" +#include "testbench/file.h" FILE *file; char pipeline_string[DEBUG_MSG_LEN]; @@ -168,7 +169,7 @@ static int tplg_load_fileread(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -226,7 +227,7 @@ static int tplg_load_filewrite(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -572,7 +573,7 @@ static int process_append_data(struct sof_ipc_comp_process **process_ipc, *process_ipc = malloc(ipc_size); if (!(*process_ipc)) { fprintf(stderr, "error: Failed to allocate IPC\n"); - return -ENOMEM; + return -errno; } /* Copy header */ @@ -689,16 +690,22 @@ int parse_topology(struct sof *sof, struct shared_lib_table *library_table, lib_table = library_table; /* file size */ - fseek(file, 0, SEEK_END); + if (fseek(file, 0, SEEK_END)) { + fprintf(stderr, "error: seek to end of topology\n"); + return -errno; + } file_size = ftell(file); - fseek(file, 0, SEEK_SET); + if (fseek(file, 0, SEEK_SET)) { + fprintf(stderr, "error: seek to beginning of topology\n"); + return -errno; + } /* allocate memory */ size = sizeof(struct snd_soc_tplg_hdr); hdr = (struct snd_soc_tplg_hdr *)malloc(size); if (!hdr) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } debug_print("topology parsing start\n"); @@ -750,10 +757,16 @@ int parse_topology(struct sof *sof, struct shared_lib_table *library_table, if (ftell(file) == file_size) goto finish; break; + default: - fseek(file, hdr->payload_size, SEEK_CUR); + if (fseek(file, hdr->payload_size, SEEK_CUR)) { + fprintf(stderr, "error: fseek payload size\n"); + return -errno; + } + if (ftell(file) == file_size) goto finish; + break; } } diff --git a/tools/tplg_parser/tplg_parser.c b/tools/tplg_parser/tplg_parser.c index 24e685bdd0b0..c6a235e545f7 100644 --- a/tools/tplg_parser/tplg_parser.c +++ b/tools/tplg_parser/tplg_parser.c @@ -133,7 +133,7 @@ int tplg_load_buffer(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: malloc fail during load_buffer\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -198,7 +198,7 @@ int tplg_load_pcm(int comp_id, int pipeline_id, int size, int dir, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -257,7 +257,7 @@ int tplg_load_dai(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -310,7 +310,7 @@ int tplg_load_pga(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -379,7 +379,7 @@ int tplg_load_pipeline(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* read vendor arrays */ @@ -441,7 +441,7 @@ int tplg_load_one_control(struct snd_soc_tplg_ctl_hdr **ctl, char **priv_data, ctl_hdr = (struct snd_soc_tplg_ctl_hdr *)malloc(hdr_size); if (!ctl_hdr) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* read control header */ @@ -461,14 +461,19 @@ int tplg_load_one_control(struct snd_soc_tplg_ctl_hdr **ctl, char **priv_data, case SND_SOC_TPLG_DAPM_CTL_VOLSW: /* load mixer type control */ rewind_size = sizeof(struct snd_soc_tplg_ctl_hdr); - fseek(file, rewind_size * -1, SEEK_CUR); + if (fseek(file, rewind_size * -1, SEEK_CUR)) { + ret = -errno; + goto err; + } + read_size = sizeof(struct snd_soc_tplg_mixer_control); mixer_ctl = malloc(read_size); if (!mixer_ctl) { fprintf(stderr, "error: mem alloc\n"); - ret = -EINVAL; + ret = -errno; goto err; } + ret = fread(mixer_ctl, read_size, 1, file); if (ret != 1) { ret = -EINVAL; @@ -476,7 +481,11 @@ int tplg_load_one_control(struct snd_soc_tplg_ctl_hdr **ctl, char **priv_data, } /* skip mixer private data */ - fseek(file, mixer_ctl->priv.size, SEEK_CUR); + if (fseek(file, mixer_ctl->priv.size, SEEK_CUR)) { + ret = -errno; + goto err; + } + *ctl = (struct snd_soc_tplg_ctl_hdr *)mixer_ctl; break; @@ -487,14 +496,19 @@ int tplg_load_one_control(struct snd_soc_tplg_ctl_hdr **ctl, char **priv_data, case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE: /* load enum type control */ rewind_size = sizeof(struct snd_soc_tplg_ctl_hdr); - fseek(file, rewind_size * -1, SEEK_CUR); + if (fseek(file, rewind_size * -1, SEEK_CUR)) { + ret = -errno; + goto err; + } + read_size = sizeof(struct snd_soc_tplg_enum_control); enum_ctl = malloc(read_size); if (!enum_ctl) { fprintf(stderr, "error: mem alloc\n"); - ret = -EINVAL; + ret = -errno; goto err; } + ret = fread(enum_ctl, read_size, 1, file); if (ret != 1) { ret = -EINVAL; @@ -502,19 +516,27 @@ int tplg_load_one_control(struct snd_soc_tplg_ctl_hdr **ctl, char **priv_data, } /* skip enum private data */ - fseek(file, enum_ctl->priv.size, SEEK_CUR); + if (fseek(file, enum_ctl->priv.size, SEEK_CUR)) { + ret = -errno; + goto err; + } + *ctl = (struct snd_soc_tplg_ctl_hdr *)enum_ctl; break; case SND_SOC_TPLG_CTL_BYTES: /* load bytes type controls */ rewind_size = sizeof(struct snd_soc_tplg_ctl_hdr); - fseek(file, rewind_size * -1, SEEK_CUR); + if (fseek(file, rewind_size * -1, SEEK_CUR)) { + ret = -errno; + goto err; + } + read_size = sizeof(struct snd_soc_tplg_bytes_control); bytes_ctl = malloc(read_size); if (!bytes_ctl) { fprintf(stderr, "error: mem alloc\n"); - ret = -EINVAL; + ret = -errno; goto err; } @@ -529,7 +551,7 @@ int tplg_load_one_control(struct snd_soc_tplg_ctl_hdr **ctl, char **priv_data, *priv_data = malloc(read_size); if (!(*priv_data)) { fprintf(stderr, "error: mem alloc\n"); - ret = -EINVAL; + ret = -errno; goto err; } @@ -578,7 +600,7 @@ int tplg_load_controls(int num_kcontrols, FILE *file) ctl_hdr = (struct snd_soc_tplg_ctl_hdr *)malloc(size); if (!ctl_hdr) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } size = sizeof(struct snd_soc_tplg_mixer_control); @@ -586,7 +608,7 @@ int tplg_load_controls(int num_kcontrols, FILE *file) if (!mixer_ctl) { fprintf(stderr, "error: mem alloc\n"); free(ctl_hdr); - return -EINVAL; + return -errno; } size = sizeof(struct snd_soc_tplg_enum_control); @@ -595,7 +617,7 @@ int tplg_load_controls(int num_kcontrols, FILE *file) fprintf(stderr, "error: mem alloc\n"); free(ctl_hdr); free(mixer_ctl); - return -EINVAL; + return -errno; } size = sizeof(struct snd_soc_tplg_bytes_control); @@ -605,7 +627,7 @@ int tplg_load_controls(int num_kcontrols, FILE *file) free(ctl_hdr); free(mixer_ctl); free(enum_ctl); - return -EINVAL; + return -errno; } for (j = 0; j < num_kcontrols; j++) { @@ -625,10 +647,13 @@ int tplg_load_controls(int num_kcontrols, FILE *file) case SND_SOC_TPLG_CTL_VOLSW_XR_SX: case SND_SOC_TPLG_CTL_RANGE: case SND_SOC_TPLG_DAPM_CTL_VOLSW: - /* load mixer type control */ read_size = sizeof(struct snd_soc_tplg_ctl_hdr); - fseek(file, read_size * -1, SEEK_CUR); + if (fseek(file, read_size * -1, SEEK_CUR)) { + return -errno; + goto err; + } + read_size = sizeof(struct snd_soc_tplg_mixer_control); ret = fread(mixer_ctl, read_size, 1, file); if (ret != 1) { @@ -637,17 +662,24 @@ int tplg_load_controls(int num_kcontrols, FILE *file) } /* skip mixer private data */ - fseek(file, mixer_ctl->priv.size, SEEK_CUR); + if (fseek(file, mixer_ctl->priv.size, SEEK_CUR)) { + ret = -errno; + goto err; + } break; + case SND_SOC_TPLG_CTL_ENUM: case SND_SOC_TPLG_CTL_ENUM_VALUE: case SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE: case SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT: case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE: - /* load enum type control */ read_size = sizeof(struct snd_soc_tplg_ctl_hdr); - fseek(file, read_size * -1, SEEK_CUR); + if (fseek(file, read_size * -1, SEEK_CUR)) { + ret = -errno; + goto err; + } + read_size = sizeof(struct snd_soc_tplg_enum_control); ret = fread(enum_ctl, read_size, 1, file); if (ret != 1) { @@ -656,13 +688,20 @@ int tplg_load_controls(int num_kcontrols, FILE *file) } /* skip enum private data */ - fseek(file, enum_ctl->priv.size, SEEK_CUR); + if (fseek(file, enum_ctl->priv.size, SEEK_CUR)) { + ret = -errno; + goto err; + } break; - case SND_SOC_TPLG_CTL_BYTES: + case SND_SOC_TPLG_CTL_BYTES: /* load bytes type controls */ read_size = sizeof(struct snd_soc_tplg_ctl_hdr); - fseek(file, read_size * -1, SEEK_CUR); + if (fseek(file, read_size * -1, SEEK_CUR)) { + ret = -errno; + goto err; + } + read_size = sizeof(struct snd_soc_tplg_bytes_control); ret = fread(bytes_ctl, read_size, 1, file); if (ret != 1) { @@ -671,8 +710,12 @@ int tplg_load_controls(int num_kcontrols, FILE *file) } /* skip bytes private data */ - fseek(file, bytes_ctl->priv.size, SEEK_CUR); + if (fseek(file, bytes_ctl->priv.size, SEEK_CUR)) { + ret = -errno; + goto err; + } break; + default: printf("info: control type not supported\n"); return -EINVAL; @@ -700,7 +743,7 @@ int tplg_load_src(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc for src vendor array\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -767,7 +810,7 @@ int tplg_load_asrc(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc for asrc vendor array\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -835,7 +878,7 @@ int tplg_load_process(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc for asrc vendor array\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -903,7 +946,7 @@ int tplg_load_mixer(int comp_id, int pipeline_id, int size, array = (struct snd_soc_tplg_vendor_array *)malloc(size); if (!array) { fprintf(stderr, "error: mem alloc for src vendor array\n"); - return -EINVAL; + return -errno; } /* read vendor tokens */ @@ -969,7 +1012,7 @@ int tplg_load_graph(int num_comps, int pipeline_id, graph_elem = (struct snd_soc_tplg_dapm_graph_elem *)malloc(size); if (!graph_elem) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* set up component connections */ @@ -1032,7 +1075,7 @@ int load_widget(void *dev, int dev_type, struct comp_info *temp_comp_list, widget = (struct snd_soc_tplg_dapm_widget *)malloc(size); if (!widget) { fprintf(stderr, "error: mem alloc\n"); - return -EINVAL; + return -errno; } /* read widget data */ @@ -1135,7 +1178,11 @@ int load_widget(void *dev, int dev_type, struct comp_info *temp_comp_list, break; /* unsupported widgets */ default: - fseek(file, widget->priv.size, SEEK_CUR); + if (fseek(file, widget->priv.size, SEEK_CUR)) { + fprintf(stderr, "error: fseek unsupported widget\n"); + return -errno; + } + printf("info: Widget type not supported %d\n", widget->id); ret = tplg_load_controls(widget->num_kcontrols, file); if (ret < 0) { From b5f1c7c9b91408381f086c93c2597fbc3083a1b7 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 23 Apr 2020 15:05:06 +0300 Subject: [PATCH 4/4] Testbench: Check tplg_read_array() error codes in topology parsing This patch adds the missing error codes check to avoid the parsing to continue after a possible file I/O fail. Signed-off-by: Seppo Ingalsuo --- tools/tplg_parser/tplg_parser.c | 62 ++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/tools/tplg_parser/tplg_parser.c b/tools/tplg_parser/tplg_parser.c index c6a235e545f7..b0a85199bd80 100644 --- a/tools/tplg_parser/tplg_parser.c +++ b/tools/tplg_parser/tplg_parser.c @@ -147,7 +147,12 @@ int tplg_load_buffer(int comp_id, int pipeline_id, int size, return -EINVAL; } - tplg_read_array(array, file); + ret = tplg_read_array(array, file); + if (ret) { + fprintf(stderr, "error: read array fail\n"); + free(array); + return ret; + } /* parse buffer comp tokens */ ret = sof_parse_tokens(&buffer->comp, buffer_comp_tokens, @@ -207,7 +212,14 @@ int tplg_load_pcm(int comp_id, int pipeline_id, int size, int dir, ret = fread(array, read_size, 1, file); if (ret != 1) return -EINVAL; - tplg_read_array(array, file); + + ret = tplg_read_array(array, file); + if (ret) { + fprintf(stderr, "error: read array fail\n"); + free(array); + return ret; + } + /* parse comp tokens */ ret = sof_parse_tokens(&host->config, comp_tokens, @@ -269,7 +281,12 @@ int tplg_load_dai(int comp_id, int pipeline_id, int size, return -EINVAL; } - tplg_read_array(array, file); + ret = tplg_read_array(array, file); + if (ret) { + fprintf(stderr, "error: read array fail\n"); + free(array); + return ret; + } ret = sof_parse_tokens(comp_dai, dai_tokens, ARRAY_SIZE(dai_tokens), array, @@ -321,7 +338,13 @@ int tplg_load_pga(int comp_id, int pipeline_id, int size, free(array); return -EINVAL; } - tplg_read_array(array, file); + + ret = tplg_read_array(array, file); + if (ret) { + fprintf(stderr, "error: read array fail\n"); + free(array); + return ret; + } /* parse comp tokens */ ret = sof_parse_tokens(&volume->config, comp_tokens, @@ -392,7 +415,8 @@ int tplg_load_pipeline(int comp_id, int pipeline_id, int size, } ret = tplg_read_array(array, file); - if (ret < 0) { + if (ret) { + fprintf(stderr, "error: read array fail\n"); free(array); return -EINVAL; } @@ -755,7 +779,12 @@ int tplg_load_src(int comp_id, int pipeline_id, int size, return -EINVAL; } - tplg_read_array(array, file); + ret = tplg_read_array(array, file); + if (ret) { + fprintf(stderr, "error: read array fail\n"); + free(array); + return ret; + } /* parse comp tokens */ ret = sof_parse_tokens(&src->config, comp_tokens, @@ -822,7 +851,12 @@ int tplg_load_asrc(int comp_id, int pipeline_id, int size, return -EINVAL; } - tplg_read_array(array, file); + ret = tplg_read_array(array, file); + if (ret) { + fprintf(stderr, "error: read array fail\n"); + free(array); + return ret; + } /* parse comp tokens */ ret = sof_parse_tokens(&asrc->config, comp_tokens, @@ -890,7 +924,12 @@ int tplg_load_process(int comp_id, int pipeline_id, int size, return -EINVAL; } - tplg_read_array(array, file); + ret = tplg_read_array(array, file); + if (ret) { + fprintf(stderr, "error: read array fail\n"); + free(array); + return ret; + } /* parse comp tokens */ ret = sof_parse_tokens(&process->config, comp_tokens, @@ -958,7 +997,12 @@ int tplg_load_mixer(int comp_id, int pipeline_id, int size, return -EINVAL; } - tplg_read_array(array, file); + ret = tplg_read_array(array, file); + if (ret) { + fprintf(stderr, "error: read array fail\n"); + free(array); + return ret; + } /* parse comp tokens */ ret = sof_parse_tokens(&mixer->config, comp_tokens,