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 at intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index 20e5beb..aaa9879 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -148,7 +148,7 @@ int
 rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params 
*params,
                const char *input_args)
 {
-       struct rte_kvargs *kvlist;
+       struct rte_kvargs *kvlist = NULL;
        int ret;

        if (params == NULL)
@@ -187,10 +187,11 @@ rte_cryptodev_parse_vdev_init_params(struct 
rte_crypto_vdev_init_params *params,
                }
        }

-       return 0;
+       ret = 0;

 free_kvlist:
-       rte_kvargs_free(kvlist);
+       if (kvlist != NULL)
+               rte_kvargs_free(kvlist);
        return ret;
 }

-- 
2.7.4

Reply via email to