From: Jaroslav Kysela Date: Fri, 4 Jun 2021 08:19:22 +0000 (+0200) Subject: topology: fix few coverity detected defects X-Git-Tag: v1.2.5.1~7 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=c58f981e1530557835461b17b92eac6c475e5f68;p=alsa-utils.git topology: fix few coverity detected defects Signed-off-by: Jaroslav Kysela --- diff --git a/topology/pre-process-dapm.c b/topology/pre-process-dapm.c index dbaf2f1..dc510e1 100644 --- a/topology/pre-process-dapm.c +++ b/topology/pre-process-dapm.c @@ -203,7 +203,8 @@ static int tplg_pp_get_widget_name(struct tplg_pre_processor *tplg_pp, if (!args) { SNDERR("insufficient arugments for widget %s\n", string); - return -EINVAL; + ret = -EINVAL; + goto err; } remaining = strchr(args + 1, '.'); diff --git a/topology/pre-process-object.c b/topology/pre-process-object.c index ac8caec..7565091 100644 --- a/topology/pre-process-object.c +++ b/topology/pre-process-object.c @@ -463,7 +463,8 @@ static snd_config_t *tplg_object_lookup_in_config(struct tplg_pre_processor *tpl if (!config_id) return NULL; - snd_config_search(class, config_id, &obj_cfg); + if (snd_config_search(class, config_id, &obj_cfg) < 0) + return NULL; free(config_id); return obj_cfg; } @@ -704,11 +705,12 @@ static int tplg_add_object_data(struct tplg_pre_processor *tplg_pp, snd_config_t ret = tplg_pp_add_object_tuple_section(tplg_pp, class_cfg, n, data_cfg_name, token); - free(data_cfg_name); if (ret < 0) { SNDERR("Failed to add data section %s\n", data_cfg_name); + free(data_cfg_name); return ret; } + free(data_cfg_name); } return 0; @@ -1215,8 +1217,10 @@ static int tplg_construct_object_name(struct tplg_pre_processor *tplg_pp, snd_co return 0; /* set class name as the name prefix for the object */ - snd_config_get_id(obj, &obj_id); - snd_config_get_id(class_cfg, &class_id); + if (snd_config_get_id(obj, &obj_id) < 0) + return -EINVAL; + if (snd_config_get_id(class_cfg, &class_id) < 0) + return -EINVAL; new_name = strdup(class_id); if (!new_name) return -ENOMEM; @@ -1280,7 +1284,8 @@ static int tplg_construct_object_name(struct tplg_pre_processor *tplg_pp, snd_co default: SNDERR("Argument '%s' in object '%s.%s' is not an integer or a string\n", s, class_id, obj_id); - return -EINVAL; + ret = -EINVAL; + goto err; } /* alloc and concat arg value to the name */ diff --git a/topology/pre-processor.c b/topology/pre-processor.c index 0458c3c..442dcc4 100644 --- a/topology/pre-processor.c +++ b/topology/pre-processor.c @@ -183,7 +183,7 @@ int init_pre_precessor(struct tplg_pre_processor **tplg_pp, snd_output_type_t ty _tplg_pp = calloc(1, sizeof(struct tplg_pre_processor)); if (!_tplg_pp) - ret = -ENOMEM; + return -ENOMEM; *tplg_pp = _tplg_pp;