From: Akash Saxena <akash.saxena@caviumnetworks.com>
To: "Verma, Shally" <Shally.Verma@cavium.com>,
"john.mcnamara@intel.com" <john.mcnamara@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"Sahu, Sunila" <Sunila.Sahu@cavium.com>,
"Athreya, Narayana Prasad" <NarayanaPrasad.Athreya@cavium.com>,
"Gupta, Ashish" <Ashish.Gupta@cavium.com>,
"pablo.de.lara.guarch@intel.com" <pablo.de.lara.guarch@intel.com>
Cc: "Saxena, Akash" <Akash.Saxena@cavium.com>
Subject: [dpdk-dev] [PATCH] crypto/openssl: Remove if condition prior to BN_free
Date: Fri, 23 Nov 2018 12:10:59 +0000 [thread overview]
Message-ID: <1542974985-31428-1-git-send-email-akash.saxena@caviumnetworks.com> (raw)
Remove if() condition prior to calling BN_free() as
BN_free(a) does nothing if a is NULL.
Signed-off-by: Akash Saxena <akash.saxena@caviumnetworks.com>
Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
---
drivers/crypto/openssl/rte_openssl_pmd.c | 21 +++++--------
drivers/crypto/openssl/rte_openssl_pmd_ops.c | 45 ++++++++++------------------
2 files changed, 22 insertions(+), 44 deletions(-)
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 11ea0d1..a0ccacb 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1605,12 +1605,9 @@ process_openssl_dsa_verify_op(struct rte_crypto_op *cop,
op->y.length,
pub_key);
if (!r || !s || !pub_key) {
- if (r)
- BN_free(r);
- if (s)
- BN_free(s);
- if (pub_key)
- BN_free(pub_key);
+ BN_free(r);
+ BN_free(s);
+ BN_free(pub_key);
cop->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
return -1;
@@ -1781,10 +1778,8 @@ process_openssl_modinv_op(struct rte_crypto_op *cop,
BIGNUM *res = BN_CTX_get(sess->u.m.ctx);
if (unlikely(base == NULL || res == NULL)) {
- if (base)
- BN_free(base);
- if (res)
- BN_free(res);
+ BN_free(base);
+ BN_free(res);
cop->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
return -1;
}
@@ -1812,10 +1807,8 @@ process_openssl_modexp_op(struct rte_crypto_op *cop,
BIGNUM *res = BN_CTX_get(sess->u.e.ctx);
if (unlikely(base == NULL || res == NULL)) {
- if (base)
- BN_free(base);
- if (res)
- BN_free(res);
+ BN_free(base);
+ BN_free(res);
cop->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
return -1;
}
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index c2b029e..bdaf937 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -906,22 +906,14 @@ static int openssl_set_asym_session_parameters(
asym_session->xfrm_type = RTE_CRYPTO_ASYM_XFORM_RSA;
break;
err_rsa:
- if (n)
- BN_free(n);
- if (e)
- BN_free(e);
- if (d)
- BN_free(d);
- if (p)
- BN_free(p);
- if (q)
- BN_free(q);
- if (dmp1)
- BN_free(dmp1);
- if (dmq1)
- BN_free(dmq1);
- if (iqmp)
- BN_free(iqmp);
+ BN_free(n);
+ BN_free(e);
+ BN_free(d);
+ BN_free(p);
+ BN_free(q);
+ BN_free(dmp1);
+ BN_free(dmq1);
+ BN_free(iqmp);
return -1;
}
@@ -1043,10 +1035,8 @@ static int openssl_set_asym_session_parameters(
err_dh:
OPENSSL_LOG(ERR, " failed to set dh params\n");
- if (p)
- BN_free(p);
- if (g)
- BN_free(g);
+ BN_free(p);
+ BN_free(g);
return -1;
}
case RTE_CRYPTO_ASYM_XFORM_DSA:
@@ -1112,16 +1102,11 @@ static int openssl_set_asym_session_parameters(
break;
err_dsa:
- if (p)
- BN_free(p);
- if (q)
- BN_free(q);
- if (g)
- BN_free(g);
- if (priv_key)
- BN_free(priv_key);
- if (pub_key)
- BN_free(pub_key);
+ BN_free(p);
+ BN_free(q);
+ BN_free(g);
+ BN_free(priv_key);
+ BN_free(pub_key);
return -1;
}
default:
--
2.7.4
next reply other threads:[~2018-11-23 12:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-23 12:10 Akash Saxena [this message]
2018-12-18 10:21 ` 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=1542974985-31428-1-git-send-email-akash.saxena@caviumnetworks.com \
--to=akash.saxena@caviumnetworks.com \
--cc=Akash.Saxena@cavium.com \
--cc=Ashish.Gupta@cavium.com \
--cc=NarayanaPrasad.Athreya@cavium.com \
--cc=Shally.Verma@cavium.com \
--cc=Sunila.Sahu@cavium.com \
--cc=dev@dpdk.org \
--cc=john.mcnamara@intel.com \
--cc=pablo.de.lara.guarch@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).