crypto/octeontx2: fix sessionless code
diff mbox series

Message ID 20200908091930.24422-1-adwivedi@marvell.com
State Superseded
Delegated to: akhil goyal
Headers show
Series
  • crypto/octeontx2: fix sessionless code
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Ankur Dwivedi Sept. 8, 2020, 9:19 a.m. UTC
A temporary session is created for sessionless crypto operations.
rte_cryptodev_sym_session_create() should be used for creating the
temporary session as it initializes the session structure in the
correct way. Also the session should be set to 0 before freeing it.

Fixes: 17ac2a72191b ("crypto/octeontx2: add enqueue/dequeue ops")

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
 drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Anoob Joseph Sept. 8, 2020, 11 a.m. UTC | #1
> A temporary session is created for sessionless crypto operations.
> rte_cryptodev_sym_session_create() should be used for creating the
> temporary session as it initializes the session structure in the correct way.
> Also the session should be set to 0 before freeing it.
> 
> Fixes: 17ac2a72191b ("crypto/octeontx2: add enqueue/dequeue ops")
> 
> Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>

Acked-by: Anoob Joseph <anoobj@marvell.com>

Patch
diff mbox series

diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c
index 9d51b17dd..ccf566d5f 100644
--- a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c
+++ b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c
@@ -648,8 +648,8 @@  otx2_cpt_enqueue_sym_sessless(struct otx2_cpt_qp *qp, struct rte_crypto_op *op,
 	int ret;
 
 	/* Create temporary session */
-
-	if (rte_mempool_get(qp->sess_mp, (void **)&sess))
+	sess = rte_cryptodev_sym_session_create(qp->sess_mp);
+	if (sess == NULL)
 		return -ENOMEM;
 
 	ret = sym_session_configure(driver_id, sym_op->xform, sess,
@@ -894,6 +894,9 @@  otx2_cpt_dequeue_post_process(struct otx2_cpt_qp *qp, struct rte_crypto_op *cop,
 		if (unlikely(cop->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) {
 			sym_session_clear(otx2_cryptodev_driver_id,
 					  cop->sym->session);
+			memset(cop->sym->session, 0,
+			rte_cryptodev_sym_get_existing_header_session_size(
+				cop->sym->session));
 			rte_mempool_put(qp->sess_mp, cop->sym->session);
 			cop->sym->session = NULL;
 		}