patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	stable@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>,
	Kai Ji <kai.ji@intel.com>, Ciara Power <ciara.power@intel.com>,
	Fan Zhang <fanzhang.oss@gmail.com>
Subject: [PATCH v6 04/11] crypto/qat: fix size calculation for memset
Date: Thu, 13 Feb 2025 14:16:17 -0800	[thread overview]
Message-ID: <20250213221819.1856769-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org>

The memset was always doing 0 bytes since size computed later.

Link: https://pvs-studio.com/en/blog/posts/cpp/1179/

Fixes: 3a80d7fb2ecd ("crypto/qat: support SHA3 plain hash")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/crypto/qat/qat_sym_session.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c
index 3564a33484..7836c95064 100644
--- a/drivers/crypto/qat/qat_sym_session.c
+++ b/drivers/crypto/qat/qat_sym_session.c
@@ -2347,7 +2347,7 @@ int qat_sym_cd_cipher_set(struct qat_sym_session *cdesc,
 	return 0;
 }
 
-int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
+static int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 		const uint8_t *authkey,
 		uint32_t authkeylen,
 		uint32_t aad_length,
@@ -2620,27 +2620,27 @@ int qat_sym_cd_auth_set(struct qat_sym_session *cdesc,
 		break;
 	case ICP_QAT_HW_AUTH_ALGO_SHA3_224:
 		/* Plain SHA3-224 */
-		memset(cdesc->cd_cur_ptr, 0, state1_size);
 		state1_size = qat_hash_get_state1_size(
 				cdesc->qat_hash_alg);
+		memset(cdesc->cd_cur_ptr, 0, state1_size);
 		break;
 	case ICP_QAT_HW_AUTH_ALGO_SHA3_256:
 		/* Plain SHA3-256 */
-		memset(cdesc->cd_cur_ptr, 0, state1_size);
 		state1_size = qat_hash_get_state1_size(
 				cdesc->qat_hash_alg);
+		memset(cdesc->cd_cur_ptr, 0, state1_size);
 		break;
 	case ICP_QAT_HW_AUTH_ALGO_SHA3_384:
 		/* Plain SHA3-384 */
-		memset(cdesc->cd_cur_ptr, 0, state1_size);
 		state1_size = qat_hash_get_state1_size(
 				cdesc->qat_hash_alg);
+		memset(cdesc->cd_cur_ptr, 0, state1_size);
 		break;
 	case ICP_QAT_HW_AUTH_ALGO_SHA3_512:
 		/* Plain SHA3-512 */
-		memset(cdesc->cd_cur_ptr, 0, state1_size);
 		state1_size = qat_hash_get_state1_size(
 				cdesc->qat_hash_alg);
+		memset(cdesc->cd_cur_ptr, 0, state1_size);
 		break;
 	case ICP_QAT_HW_AUTH_ALGO_AES_XCBC_MAC:
 		state1_size = ICP_QAT_HW_AES_XCBC_MAC_STATE1_SZ;
-- 
2.47.2


  parent reply	other threads:[~2025-02-13 22:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20241114011129.451243-1-stephen@networkplumber.org>
     [not found] ` <20241114015405.77060-1-stephen@networkplumber.org>
2024-11-14  1:52   ` [PATCH v2 4/8] " Stephen Hemminger
     [not found] ` <20241114023738.141821-1-stephen@networkplumber.org>
2024-11-14  2:35   ` [PATCH v3 04/11] " Stephen Hemminger
     [not found] ` <20241114184452.31854-1-stephen@networkplumber.org>
2024-11-14 18:43   ` [PATCH v4 04/12] " Stephen Hemminger
     [not found] ` <20250211173720.1188517-1-stephen@networkplumber.org>
2025-02-11 17:35   ` [PATCH v5 04/11] " Stephen Hemminger
2025-02-11 17:35   ` [PATCH v5 09/11] net/ntnic: check result of malloc Stephen Hemminger
     [not found] ` <20250213221819.1856769-1-stephen@networkplumber.org>
2025-02-13 22:16   ` Stephen Hemminger [this message]
2025-02-13 22:16   ` [PATCH v6 " Stephen Hemminger
     [not found] ` <20250215190544.988310-1-stephen@networkplumber.org>
2025-02-15 19:04   ` [PATCH v7 09/16] crypto/qat: fix size calculation for memset Stephen Hemminger
2025-02-15 19:04   ` [PATCH v7 14/16] net/ntnic: check result of malloc Stephen Hemminger
     [not found] ` <20250216170110.7230-1-stephen@networkplumber.org>
2025-02-16 16:53   ` [PATCH v8 10/17] crypto/qat: fix size calculation for memset Stephen Hemminger
2025-02-16 16:53   ` [PATCH v8 15/17] net/ntnic: check result of malloc Stephen Hemminger
     [not found] ` <20250220164151.9606-1-stephen@networkplumber.org>
2025-02-20 16:27   ` [PATCH v9 08/15] crypto/qat: fix size calculation for memset Stephen Hemminger
2025-02-20 16:27   ` [PATCH v9 13/15] net/ntnic: check result of malloc Stephen Hemminger

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=20250213221819.1856769-5-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=bruce.richardson@intel.com \
    --cc=ciara.power@intel.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=kai.ji@intel.com \
    --cc=stable@dpdk.org \
    /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).