Skip to content

Commit

Permalink
crypto/dpaa2_sec: fix memory allocation check
Browse files Browse the repository at this point in the history
[ upstream commit 9a494a3 ]

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: 8d1f3a5 ("crypto/dpaa2_sec: support crypto operation")

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
  • Loading branch information
Gagandeep Singh authored and bluca committed Feb 4, 2021
1 parent 4b22a80 commit fc49e71
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fc49e71

Please sign in to comment.