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>
---

Changes in v2:
- Initialize ret variable to 0 (success)

 lib/librte_cryptodev/rte_cryptodev.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index 20e5beb..db809d8 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -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,10 +187,9 @@ rte_cryptodev_parse_vdev_init_params(struct 
rte_crypto_vdev_init_params *params,
                }
        }

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

-- 
2.7.4

Reply via email to