DPDK patches and discussions
 help / color / mirror / Atom feed
From: <kirankumark@marvell.com>
To: Ankur Dwivedi <adwivedi@marvell.com>,
	Anoob Joseph <anoobj@marvell.com>,
	Tejasree Kondoj <ktejasree@marvell.com>
Cc: <dev@dpdk.org>, Kiran Kumar K <kirankumark@marvell.com>
Subject: [dpdk-dev] [PATCH] crypto/cnxk: add null check for rsa param key data
Date: Mon, 26 Jul 2021 10:14:19 +0530	[thread overview]
Message-ID: <20210726044419.2231610-1-kirankumark@marvell.com> (raw)

From: Kiran Kumar K <kirankumark@marvell.com>

Coverity is reporting FORWARD_NULL issue when qt data is NULL.
Adding NULL check for this.

Coverity issue: 371893
Fixes: 5a3513caeb455 ("crypto/cnxk: add asymmetric session ops")

Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
---
 drivers/crypto/cnxk/cnxk_ae.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index c752e62ea5..a71e7ee8a2 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -85,6 +85,9 @@ cnxk_ae_fill_rsa_params(struct cnxk_ae_sess *sess,
 	size_t len = (mod_len / 2);
 	uint64_t total_size;
 
+	if (qt.p.length != 0 && qt.p.data == NULL)
+		return -EINVAL;
+
 	/* Make sure key length used is not more than mod_len/2 */
 	if (qt.p.data != NULL)
 		len = RTE_MIN(len, qt.p.length);
@@ -109,7 +112,8 @@ cnxk_ae_fill_rsa_params(struct cnxk_ae_sess *sess,
 		rsa->qt.dQ.data = rsa->qt.q.data + qt.q.length;
 		memcpy(rsa->qt.dQ.data, qt.dQ.data, qt.dQ.length);
 		rsa->qt.p.data = rsa->qt.dQ.data + qt.dQ.length;
-		memcpy(rsa->qt.p.data, qt.p.data, qt.p.length);
+		if (qt.p.data != NULL)
+			memcpy(rsa->qt.p.data, qt.p.data, qt.p.length);
 		rsa->qt.dP.data = rsa->qt.p.data + qt.p.length;
 		memcpy(rsa->qt.dP.data, qt.dP.data, qt.dP.length);
 		rsa->qt.qInv.data = rsa->qt.dP.data + qt.dP.length;
-- 
2.25.1


             reply	other threads:[~2021-07-26  4:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26  4:44 kirankumark [this message]
2021-07-27 17:52 ` [dpdk-dev] [EXT] " 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=20210726044419.2231610-1-kirankumark@marvell.com \
    --to=kirankumark@marvell.com \
    --cc=adwivedi@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=ktejasree@marvell.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).