From 675ba7069148c7b18f3c74a66938dd34ee8ca653 Mon Sep 17 00:00:00 2001 From: Kiran Kumar K Date: Mon, 26 Jul 2021 10:14:19 +0530 Subject: [PATCH] crypto/cnxk: add null check for RSA key data Coverity is reporting FORWARD_NULL issue when qt data is NULL. Adding NULL check for this. Coverity issue: 371893 Fixes: 5a3513caeb45 ("crypto/cnxk: add asymmetric session") Signed-off-by: Kiran Kumar K Acked-by: Akhil Goyal --- 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 174a940ab8..00dc75ef9d 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.20.1