[2/2] crypto/dpaa2_sec: fix if check on memory allocation
Checks
Commit Message
When key length is 0, zmalloc will return NULL pointor
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: akhil.goyal@nxp.com
---
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
> When key length is 0, zmalloc will return NULL pointor
> 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: akhil.goyal@nxp.com
> ---
Signed-off missing. Will add it while merging in crypto tree.
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
@@ -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;