DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ji, Kai" <kai.ji@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [PATCH 2/2] crypto/openssl: remove unnecessary NULL checks before free
Date: Tue, 7 Nov 2023 14:12:06 +0000	[thread overview]
Message-ID: <SN6PR11MB3408870A278361D0713AA54781A9A@SN6PR11MB3408.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20231102230307.6138-3-stephen@networkplumber.org>

[-- Attachment #1: Type: text/plain, Size: 3555 bytes --]

Acked-by: Kai Ji <kai.ji@intel.com>
________________________________
From: Stephen Hemminger <stephen@networkplumber.org>
Sent: 02 November 2023 23:02
To: dev@dpdk.org <dev@dpdk.org>
Cc: Stephen Hemminger <stephen@networkplumber.org>; Ji, Kai <kai.ji@intel.com>
Subject: [PATCH 2/2] crypto/openssl: remove unnecessary NULL checks before free

Found with nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/openssl/rte_openssl_pmd.c     | 36 +++++++-------------
 drivers/crypto/openssl/rte_openssl_pmd_ops.c |  3 +-
 2 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index c234882417..090320602d 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1957,10 +1957,8 @@ process_openssl_dsa_sign_op_evp(struct rte_crypto_op *cop,
 err_dsa_sign:
         if (params)
                 OSSL_PARAM_free(params);
-       if (key_ctx)
-               EVP_PKEY_CTX_free(key_ctx);
-       if (dsa_ctx)
-               EVP_PKEY_CTX_free(dsa_ctx);
+       EVP_PKEY_CTX_free(key_ctx);
+       EVP_PKEY_CTX_free(dsa_ctx);
         return -1;
 }

@@ -2039,10 +2037,8 @@ process_openssl_dsa_verify_op_evp(struct rte_crypto_op *cop,
                 DSA_SIG_free(sign);
         if (params)
                 OSSL_PARAM_free(params);
-       if (key_ctx)
-               EVP_PKEY_CTX_free(key_ctx);
-       if (dsa_ctx)
-               EVP_PKEY_CTX_free(dsa_ctx);
+       EVP_PKEY_CTX_free(key_ctx);
+       EVP_PKEY_CTX_free(dsa_ctx);

         return ret;
 }
@@ -2294,16 +2290,12 @@ process_openssl_dh_op_evp(struct rte_crypto_op *cop,
         ret = 0;

  err_dh:
-       if (pub_key)
-               BN_free(pub_key);
-       if (priv_key)
-               BN_free(priv_key);
+       BN_free(pub_key);
+       BN_free(priv_key);
         if (params)
                 OSSL_PARAM_free(params);
-       if (dhpkey)
-               EVP_PKEY_free(dhpkey);
-       if (peerkey)
-               EVP_PKEY_free(peerkey);
+       EVP_PKEY_free(dhpkey);
+       EVP_PKEY_free(peerkey);

         EVP_PKEY_CTX_free(dh_ctx);

@@ -2880,17 +2872,13 @@ process_openssl_sm2_op_evp(struct rte_crypto_op *cop,
         ret = 0;
         cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 err_sm2:
-       if (kctx)
-               EVP_PKEY_CTX_free(kctx);
+       EVP_PKEY_CTX_free(kctx);

-       if (sctx)
-               EVP_PKEY_CTX_free(sctx);
+       EVP_PKEY_CTX_free(sctx);

-       if (cctx)
-               EVP_PKEY_CTX_free(cctx);
+       EVP_PKEY_CTX_free(cctx);

-       if (pkey)
-               EVP_PKEY_free(pkey);
+       EVP_PKEY_free(pkey);

         return ret;
 }
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 2862c294a9..419a767817 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -1431,8 +1431,7 @@ static void openssl_reset_asym_session(struct openssl_asym_session *sess)
         switch (sess->xfrm_type) {
         case RTE_CRYPTO_ASYM_XFORM_RSA:
 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
-               if (sess->u.r.ctx)
-                       EVP_PKEY_CTX_free(sess->u.r.ctx);
+               EVP_PKEY_CTX_free(sess->u.r.ctx);
 #else
                 if (sess->u.r.rsa)
                         RSA_free(sess->u.r.rsa);
--
2.41.0


[-- Attachment #2: Type: text/html, Size: 7679 bytes --]

  reply	other threads:[~2023-11-07 14:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 23:02 [PATCH 0/2] remove unnecessary null checks in OpenSSL usage Stephen Hemminger
2023-11-02 23:02 ` [PATCH 1/2] nullfree: add matches for null free cases from OpenSSL Stephen Hemminger
2023-11-02 23:02 ` [PATCH 2/2] crypto/openssl: remove unnecessary NULL checks before free Stephen Hemminger
2023-11-07 14:12   ` Ji, Kai [this message]
2023-11-09 20:12 ` [EXT] [PATCH 0/2] remove unnecessary null checks in OpenSSL usage 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=SN6PR11MB3408870A278361D0713AA54781A9A@SN6PR11MB3408.namprd11.prod.outlook.com \
    --to=kai.ji@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.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).