From 9a494a3b90aad48f5f3f4ced14104f3347723c1b Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 25 Jan 2021 16:15:34 +0800 Subject: [PATCH] crypto/dpaa2_sec: fix memory allocation check When key length is 0, zmalloc will return NULL pointer and in that case it should not return NOMEM. So in this patch, adding a check on key length. Fixes: 8d1f3a5d751b ("crypto/dpaa2_sec: support crypto operation") Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh Acked-by: Akhil Goyal --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index cab79db3dc..05b194ccff 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -1842,7 +1842,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev, session->ctxt_type = DPAA2_SEC_CIPHER; session->cipher_key.data = rte_zmalloc(NULL, xform->cipher.key.length, RTE_CACHE_LINE_SIZE); - if (session->cipher_key.data == NULL) { + if (session->cipher_key.data == NULL && xform->cipher.key.length > 0) { DPAA2_SEC_ERR("No Memory for cipher key"); rte_free(priv); return -ENOMEM; -- 2.20.1