cryptodev: fix memory leak in parameter parsing
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Mon, 18 Jul 2016 13:21:04 +0000 (14:21 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 22 Jul 2016 09:53:32 +0000 (11:53 +0200)
When parsing the parameters for virtual device initialization,
rte_kvargs structure was being freed only if there was an error,
not when parsing was successful.

Coverity issue: 124568
Fixes: f3e764fa2fb7 ("cryptodev: uninline parameter parsing")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Reshma Pattan <reshma.pattan@intel.com>
lib/librte_cryptodev/rte_cryptodev.c

index 20e5beb..fc4123b 100644 (file)
@@ -148,8 +148,8 @@ int
 rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
                const char *input_args)
 {
-       struct rte_kvargs *kvlist;
-       int ret;
+       struct rte_kvargs *kvlist = NULL;
+       int ret = 0;
 
        if (params == NULL)
                return -EINVAL;
@@ -187,8 +187,6 @@ rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
                }
        }
 
-       return 0;
-
 free_kvlist:
        rte_kvargs_free(kvlist);
        return ret;