DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yong Wang <wang.yong19@zte.com.cn>
To: hemant.agrawal@nxp.com, beilei.xing@intel.com,
	wenzhuo.lu@intel.com, john.griffin@intel.com
Cc: dev@dpdk.org, Yong Wang <wang.yong19@zte.com.cn>
Subject: [dpdk-dev] [PATCH v2 4/4] crypto/qat: add null point check and fix mem leak
Date: Wed, 20 Dec 2017 05:23:18 -0500	[thread overview]
Message-ID: <1513765398-3716-4-git-send-email-wang.yong19@zte.com.cn> (raw)
In-Reply-To: <1513765398-3716-1-git-send-email-wang.yong19@zte.com.cn>

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
 drivers/crypto/qat/qat_adf/qat_algs_build_desc.c | 10 ++++++++++
 drivers/crypto/qat/qat_qp.c                      |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
index db6c9a3..26f854c 100644
--- a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
+++ b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
@@ -359,6 +359,11 @@ static int qat_alg_do_precomputes(enum icp_qat_hw_auth_algo hash_alg,
 
 		in = rte_zmalloc("working mem for key",
 				ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ, 16);
+		if (in == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc memory");
+			return -ENOMEM;
+		}
+
 		rte_memcpy(in, qat_aes_xcbc_key_seed,
 				ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ);
 		for (x = 0; x < HASH_XCBC_PRECOMP_KEY_NUM; x++) {
@@ -389,6 +394,11 @@ static int qat_alg_do_precomputes(enum icp_qat_hw_auth_algo hash_alg,
 				ICP_QAT_HW_GALOIS_E_CTR0_SZ);
 		in = rte_zmalloc("working mem for key",
 				ICP_QAT_HW_GALOIS_H_SZ, 16);
+		if (in == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc memory");
+			return -ENOMEM;
+		}
+
 		memset(in, 0, ICP_QAT_HW_GALOIS_H_SZ);
 		if (AES_set_encrypt_key(auth_key, auth_keylen << 3,
 			&enc_key) != 0) {
diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c
index ced3aa6..8c40c94 100644
--- a/drivers/crypto/qat/qat_qp.c
+++ b/drivers/crypto/qat/qat_qp.c
@@ -180,6 +180,11 @@ int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
 	qp->op_cookies = rte_zmalloc("qat PMD op cookie pointer",
 			qp_conf->nb_descriptors * sizeof(*qp->op_cookies),
 			RTE_CACHE_LINE_SIZE);
+	if (qp->op_cookies == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc mem for cookie");
+		rte_free(qp);
+		return -ENOMEM;
+	}
 
 	qp->mmap_bar_addr = pci_dev->mem_resource[0].addr;
 	qp->inflights16 = 0;
@@ -221,7 +226,7 @@ int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
 	for (i = 0; i < qp->nb_descriptors; i++) {
 		if (rte_mempool_get(qp->op_cookie_pool, &qp->op_cookies[i])) {
 			PMD_DRV_LOG(ERR, "QAT PMD Cannot get op_cookie");
-			return -EFAULT;
+			goto create_err;
 		}
 
 		struct qat_crypto_op_cookie *sql_cookie =
@@ -246,6 +251,7 @@ int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
 	return 0;
 
 create_err:
+	rte_free(qp->op_cookies);
 	rte_free(qp);
 	return -EFAULT;
 }
-- 
1.8.3.1

  parent reply	other threads:[~2017-12-20 10:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 10:23 [dpdk-dev] [PATCH v2 1/4] net/dpaa: " Yong Wang
2017-12-20 10:23 ` [dpdk-dev] [PATCH v2 2/4] net/i40e: " Yong Wang
2017-12-27  6:41   ` Xing, Beilei
2017-12-20 10:23 ` [dpdk-dev] [PATCH v2 3/4] net/e1000: add null point check for rte_zmalloc Yong Wang
2017-12-20 10:23 ` Yong Wang [this message]
2017-12-20 12:22   ` [dpdk-dev] [PATCH v2 4/4] crypto/qat: add null point check and fix mem leak Trahe, Fiona
2017-12-20 12:58 ` [dpdk-dev] [PATCH v2 1/4] net/dpaa: " Shreyansh Jain
2018-01-17 23:00 ` Thomas Monjalon
2018-01-22  2:53   ` [dpdk-dev] 答复: " wang.yong19
2018-01-22  7:51     ` Thomas Monjalon

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=1513765398-3716-4-git-send-email-wang.yong19@zte.com.cn \
    --to=wang.yong19@zte.com.cn \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=john.griffin@intel.com \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).