DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gagandeep Singh <g.singh@nxp.com>
To: dev@dpdk.org, akhil.goyal@nxp.com
Cc: thomas@monjalon.net, Gagandeep Singh <g.singh@nxp.com>
Subject: [dpdk-dev] [PATCH 2/2] crypto/dpaa2_sec: fix if check on memory allocation
Date: Mon, 25 Jan 2021 16:15:34 +0800
Message-ID: <1611562534-6699-2-git-send-email-g.singh@nxp.com> (raw)
In-Reply-To: <1611562534-6699-1-git-send-email-g.singh@nxp.com>

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(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index cab79db..05b194c 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,
-	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");
 		return -ENOMEM;

  reply	other threads:[~2021-01-25  8:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25  8:15 [dpdk-dev] [PATCH 1/2] test/ipsec: fix return values Gagandeep Singh
2021-01-25  8:15 ` Gagandeep Singh [this message]
2021-01-27 19:53   ` [dpdk-dev] [PATCH 2/2] crypto/dpaa2_sec: fix if check on memory allocation Akhil Goyal
2021-01-27 19:54 ` [dpdk-dev] [PATCH 1/2] test/ipsec: fix return values Akhil Goyal
2021-01-27 20:00   ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1611562534-6699-2-git-send-email-g.singh@nxp.com \
    --to=g.singh@nxp.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git