]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: fix few coverity detected defects
authorJaroslav Kysela <perex@perex.cz>
Fri, 4 Jun 2021 08:19:22 +0000 (10:19 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 4 Jun 2021 08:19:41 +0000 (10:19 +0200)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology/pre-process-dapm.c
topology/pre-process-object.c
topology/pre-processor.c

index dbaf2f113f0b1dc1a5f25290900a145219b0e1f0..dc510e15d225e516f5efc01cbca30cd85d151862 100644 (file)
@@ -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, '.');
index ac8caeca425e6e1f676624ae3d95f8a94a95bc65..75650911d8cfe78a0cfae4f4f06f99cccb15e392 100644 (file)
@@ -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 */
index 0458c3ccec0b96b545548730182c99747ae57099..442dcc4e712cc088397a6028e113ec06befe2ad9 100644 (file)
@@ -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;