DPDK patches and discussions
 help / color / mirror / Atom feed
From: Arek Kusztal <arkadiuszx.kusztal@intel.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, kai.ji@intel.com,
	Arek Kusztal <arkadiuszx.kusztal@intel.com>
Subject: [PATCH v2 1/3] crypto/qat: fix uncleared cookies in asym
Date: Tue, 18 Oct 2022 14:53:32 +0100	[thread overview]
Message-ID: <20221018135334.34873-1-arkadiuszx.kusztal@intel.com> (raw)

Fixed incorrectly placed clean function in asym response.

Fixes: 002486db239e ("crypto/qat: refactor asymmetric session")

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
v2:
- fixed compilation issues
- split into 3 patches

 drivers/crypto/qat/qat_asym.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index 19931791c4..3d7a800392 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -129,20 +129,23 @@ cleanup_crt(struct qat_asym_op_cookie *cookie,
 
 static void
 cleanup(struct qat_asym_op_cookie *cookie,
-		struct rte_crypto_asym_xform *xform, int alg_size)
+		struct rte_crypto_asym_xform *xform)
 {
 	if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX)
 		cleanup_arrays(cookie, QAT_ASYM_MODEXP_NUM_IN_PARAMS,
-				QAT_ASYM_MODEXP_NUM_OUT_PARAMS, alg_size);
+				QAT_ASYM_MODEXP_NUM_OUT_PARAMS,
+				cookie->alg_bytesize);
 	else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV)
 		cleanup_arrays(cookie, QAT_ASYM_MODINV_NUM_IN_PARAMS,
-				QAT_ASYM_MODINV_NUM_OUT_PARAMS, alg_size);
+				QAT_ASYM_MODINV_NUM_OUT_PARAMS,
+				cookie->alg_bytesize);
 	else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {
 		if (xform->rsa.key_type == RTE_RSA_KEY_TYPE_QT)
-			cleanup_crt(cookie, alg_size);
+			cleanup_crt(cookie, cookie->alg_bytesize);
 		else {
 			cleanup_arrays(cookie, QAT_ASYM_RSA_NUM_IN_PARAMS,
-				QAT_ASYM_RSA_NUM_OUT_PARAMS, alg_size);
+				QAT_ASYM_RSA_NUM_OUT_PARAMS,
+				cookie->alg_bytesize);
 		}
 	} else {
 		cleanup_arrays(cookie, QAT_ASYM_MAX_PARAMS,
@@ -804,12 +807,13 @@ qat_asym_build_request(void *in_op, uint8_t *out_msg, void *op_cookie,
 			op->asym->session->sess_private_data;
 	int err = 0;
 
+	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
 	if (unlikely(qat_session == NULL)) {
 		QAT_DP_LOG(ERR, "Session was not created for this device");
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
 		goto error;
 	}
 
-	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
 	switch (op->sess_type) {
 	case RTE_CRYPTO_OP_WITH_SESSION:
 		request_init(qat_req);
@@ -882,10 +886,11 @@ qat_asym_process_response(void **out_op, uint8_t *resp,
 	struct rte_crypto_op *op = (struct rte_crypto_op *)(uintptr_t)
 			(resp_msg->opaque);
 	struct qat_asym_op_cookie *cookie = op_cookie;
-	struct rte_crypto_asym_xform *xform;
+	struct rte_crypto_asym_xform *xform = NULL;
 	struct qat_asym_session *qat_session = (struct qat_asym_session *)
 			op->asym->session->sess_private_data;
 
+	*out_op = op;
 	if (cookie->error) {
 		cookie->error = 0;
 		if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
@@ -917,17 +922,13 @@ qat_asym_process_response(void **out_op, uint8_t *resp,
 	default:
 		QAT_DP_LOG(ERR,
 			"Invalid session/xform settings in response ring!");
-		op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
-	}
-
-	if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) {
-		op->status = qat_asym_collect_response(op,
-					cookie, xform);
-		cleanup(cookie, xform, cookie->alg_bytesize);
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
 	}
-
-	*out_op = op;
+	if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
+		op->status = qat_asym_collect_response(op, cookie, xform);
 	HEXDUMP("resp_msg:", resp_msg, sizeof(struct icp_qat_fw_pke_resp));
+	if (likely(xform != NULL))
+		cleanup(cookie, xform);
 
 	return 1;
 }
-- 
2.13.6


             reply	other threads:[~2022-10-18 15:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 13:53 Arek Kusztal [this message]
2022-10-18 13:53 ` [PATCH v2 2/3] crypto/qat: fix unnecessary session check Arek Kusztal
2022-10-21  8:29   ` Power, Ciara
2022-10-18 13:53 ` [PATCH v2 3/3] crypto/qat: fix not set rsa lengths Arek Kusztal
2022-10-21  8:29   ` Power, Ciara
2022-10-21  8:29 ` [PATCH v2 1/3] crypto/qat: fix uncleared cookies in asym Power, Ciara
2022-10-21 13:29   ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221018135334.34873-1-arkadiuszx.kusztal@intel.com \
    --to=arkadiuszx.kusztal@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=kai.ji@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).