Skip to content

Commit

Permalink
security: fix session counter
Browse files Browse the repository at this point in the history
[ upstream commit e36b5a8 ]

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: c261d14 ("security: introduce security API and framework")

Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
  • Loading branch information
lukaszwojciechowski authored and kevintraynor committed May 27, 2020
1 parent d0819d0 commit 55e69e8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/librte_security/rte_security.c
Expand Up @@ -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
Expand Down

0 comments on commit 55e69e8

Please sign in to comment.