From: Lukasz Wojciechowski Date: Thu, 9 Apr 2020 17:24:52 +0000 (+0200) Subject: security: fix session counter X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e36b5a87d6d0e1e209d85dc22419924cbe02056c;p=dpdk.git security: fix session counter Fix session counter to be decreased in rte_security_session_destroy only when session was successfully destroyed. Formerly session counter was decreased prior session destroying and returning session object to mempool. It remained decreased even if session was not destroyed and mempool object released making counter invalid. Fixes: c261d1431bd8 ("security: introduce security API and framework") Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: Anoob Joseph Acked-by: Akhil Goyal --- diff --git a/lib/librte_security/rte_security.c b/lib/librte_security/rte_security.c index 38ccc2ea9c..d475b09771 100644 --- a/lib/librte_security/rte_security.c +++ b/lib/librte_security/rte_security.c @@ -90,14 +90,16 @@ rte_security_session_destroy(struct rte_security_ctx *instance, -ENOTSUP); RTE_PTR_OR_ERR_RET(sess, -EINVAL); + ret = instance->ops->session_destroy(instance->device, sess); + if (ret != 0) + return ret; + + rte_mempool_put(rte_mempool_from_obj(sess), (void *)sess); + if (instance->sess_cnt) instance->sess_cnt--; - ret = instance->ops->session_destroy(instance->device, sess); - if (!ret) - rte_mempool_put(rte_mempool_from_obj(sess), (void *)sess); - - return ret; + return 0; } int