diff mbox series

[v2,03/13] security: fix session counter

Message ID 20200408031351.4288-4-l.wojciechow@partner.samsung.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers show
Series Fixes and unit tests for librte_security | expand


Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Lukasz Wojciechowski April 8, 2020, 3:13 a.m. UTC
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

Fixes: c261d1431bd8 ("security: introduce security API and framework")
Cc: akhil.goyal@nxp.com

Cc: stable@dpdk.org

Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
 lib/librte_security/rte_security.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff mbox series


diff --git a/lib/librte_security/rte_security.c b/lib/librte_security/rte_security.c
index f1b4a894e..ae57d3421 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,
+	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)
-	ret = instance->ops->session_destroy(instance->device, sess);
-	if (!ret)
-		rte_mempool_put(rte_mempool_from_obj(sess), (void *)sess);
-	return ret;
+	return 0;