diff mbox series

crypto/cnxk: add null check for rsa param key data

Message ID 20210726044419.2231610-1-kirankumark@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers show
Series crypto/cnxk: add null check for rsa param key data | expand

Checks

Context Check Description
ci/iol-testing fail Testing issues
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

Kiran Kumar Kokkilagadda July 26, 2021, 4:44 a.m. UTC
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(-)

Comments

Akhil Goyal July 27, 2021, 5:52 p.m. UTC | #1
> 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>
Acked-by: Akhil Goyal <gakhil@marvell.com>

Applied to dpdk-next-crypto
diff mbox series

Patch

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;