All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] net/i40e: add null point check and fix mem leak
@ 2018-01-23  2:44 Yong Wang
  2018-01-23  2:44 ` [PATCH v3 2/3] net/e1000: add null point check for rte_zmalloc Yong Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yong Wang @ 2018-01-23  2:44 UTC (permalink / raw)
  To: beilei.xing, wenzhuo.lu, fiona.trahe; +Cc: dev, Yong Wang

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
v2:
* Fix code style warning.
---
 drivers/net/i40e/i40e_ethdev.c | 32 ++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_fdir.c   |  7 +++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index c4df65d..277c1a8 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -7188,11 +7188,13 @@ struct i40e_tunnel_filter *
 	node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input);
 	if (add && node) {
 		PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!");
+		rte_free(cld_filter);
 		return -EINVAL;
 	}
 
 	if (!add && !node) {
 		PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!");
+		rte_free(cld_filter);
 		return -EINVAL;
 	}
 
@@ -7201,16 +7203,26 @@ struct i40e_tunnel_filter *
 					vsi->seid, &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
+			rte_free(cld_filter);
 			return -ENOTSUP;
 		}
 		tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
+		if (tunnel == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc memory.");
+			rte_free(cld_filter);
+			return -ENOMEM;
+		}
+
 		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
 		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
+		if (ret < 0)
+			rte_free(tunnel);
 	} else {
 		ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
 						   &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
+			rte_free(cld_filter);
 			return -ENOTSUP;
 		}
 		ret = i40e_sw_tunnel_filter_del(pf, &node->input);
@@ -7639,6 +7651,7 @@ i40e_status_code i40e_replace_gtp_cloud_filter(struct i40e_pf *pf)
 	else {
 		if (tunnel_filter->vf_id >= pf->vf_num) {
 			PMD_DRV_LOG(ERR, "Invalid argument.");
+			rte_free(cld_filter);
 			return -EINVAL;
 		}
 		vf = &pf->vfs[tunnel_filter->vf_id];
@@ -7653,11 +7666,13 @@ i40e_status_code i40e_replace_gtp_cloud_filter(struct i40e_pf *pf)
 	node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input);
 	if (add && node) {
 		PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!");
+		rte_free(cld_filter);
 		return -EINVAL;
 	}
 
 	if (!add && !node) {
 		PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!");
+		rte_free(cld_filter);
 		return -EINVAL;
 	}
 
@@ -7670,11 +7685,20 @@ i40e_status_code i40e_replace_gtp_cloud_filter(struct i40e_pf *pf)
 					vsi->seid, &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
+			rte_free(cld_filter);
 			return -ENOTSUP;
 		}
 		tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
+		if (tunnel == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc memory.");
+			rte_free(cld_filter);
+			return -ENOMEM;
+		}
+
 		rte_memcpy(tunnel, &check_filter, sizeof(check_filter));
 		ret = i40e_sw_tunnel_filter_insert(pf, tunnel);
+		if (ret < 0)
+			rte_free(tunnel);
 	} else {
 		if (big_buffer)
 			ret = i40e_aq_remove_cloud_filters_big_buffer(
@@ -7684,6 +7708,7 @@ i40e_status_code i40e_replace_gtp_cloud_filter(struct i40e_pf *pf)
 						   &cld_filter->element, 1);
 		if (ret < 0) {
 			PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
+			rte_free(cld_filter);
 			return -ENOTSUP;
 		}
 		ret = i40e_sw_tunnel_filter_del(pf, &node->input);
@@ -9295,9 +9320,16 @@ struct i40e_ethertype_filter *
 	if (add) {
 		ethertype_filter = rte_zmalloc("ethertype_filter",
 				       sizeof(*ethertype_filter), 0);
+		if (ethertype_filter == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc memory.");
+			return -ENOMEM;
+		}
+
 		rte_memcpy(ethertype_filter, &check_filter,
 			   sizeof(check_filter));
 		ret = i40e_sw_ethertype_filter_insert(pf, ethertype_filter);
+		if (ret < 0)
+			rte_free(ethertype_filter);
 	} else {
 		ret = i40e_sw_ethertype_filter_del(pf, &node->input);
 	}
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index a4320b1..c392dc4 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -1595,8 +1595,15 @@ static int i40e_sw_fdir_filter_insert(struct i40e_pf *pf,
 	if (add) {
 		fdir_filter = rte_zmalloc("fdir_filter",
 					  sizeof(*fdir_filter), 0);
+		if (fdir_filter == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc memory.");
+			return -ENOMEM;
+		}
+
 		rte_memcpy(fdir_filter, &check_filter, sizeof(check_filter));
 		ret = i40e_sw_fdir_filter_insert(pf, fdir_filter);
+		if (ret < 0)
+			rte_free(fdir_filter);
 	} else {
 		ret = i40e_sw_fdir_filter_del(pf, &node->fdir.input);
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/3] net/e1000: add null point check for rte_zmalloc
  2018-01-23  2:44 [PATCH v3 1/3] net/i40e: add null point check and fix mem leak Yong Wang
@ 2018-01-23  2:44 ` Yong Wang
  2018-01-23  2:45 ` [PATCH v3 3/3] crypto/qat: add null point check and fix mem leak Yong Wang
  2018-01-24  8:41 ` [PATCH v3 1/3] net/i40e: " Zhang, Helin
  2 siblings, 0 replies; 7+ messages in thread
From: Yong Wang @ 2018-01-23  2:44 UTC (permalink / raw)
  To: beilei.xing, wenzhuo.lu, fiona.trahe; +Cc: dev, Yong Wang

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
 drivers/net/e1000/igb_flow.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/e1000/igb_flow.c b/drivers/net/e1000/igb_flow.c
index d98bdc8..a142759 100644
--- a/drivers/net/e1000/igb_flow.c
+++ b/drivers/net/e1000/igb_flow.c
@@ -1413,6 +1413,11 @@
 		if (!ret) {
 			ntuple_filter_ptr = rte_zmalloc("igb_ntuple_filter",
 				sizeof(struct igb_ntuple_filter_ele), 0);
+			if (!ntuple_filter_ptr) {
+				PMD_DRV_LOG(ERR, "failed to allocate memory");
+				goto out;
+			}
+
 			rte_memcpy(&ntuple_filter_ptr->filter_info,
 				&ntuple_filter,
 				sizeof(struct rte_eth_ntuple_filter));
@@ -1435,6 +1440,11 @@
 			ethertype_filter_ptr = rte_zmalloc(
 				"igb_ethertype_filter",
 				sizeof(struct igb_ethertype_filter_ele), 0);
+			if (!ethertype_filter_ptr) {
+				PMD_DRV_LOG(ERR, "failed to allocate memory");
+				goto out;
+			}
+
 			rte_memcpy(&ethertype_filter_ptr->filter_info,
 				&ethertype_filter,
 				sizeof(struct rte_eth_ethertype_filter));
@@ -1455,6 +1465,11 @@
 		if (!ret) {
 			syn_filter_ptr = rte_zmalloc("igb_syn_filter",
 				sizeof(struct igb_eth_syn_filter_ele), 0);
+			if (!syn_filter_ptr) {
+				PMD_DRV_LOG(ERR, "failed to allocate memory");
+				goto out;
+			}
+
 			rte_memcpy(&syn_filter_ptr->filter_info,
 				&syn_filter,
 				sizeof(struct rte_eth_syn_filter));
@@ -1476,6 +1491,11 @@
 		if (!ret) {
 			flex_filter_ptr = rte_zmalloc("igb_flex_filter",
 				sizeof(struct igb_flex_filter_ele), 0);
+			if (!flex_filter_ptr) {
+				PMD_DRV_LOG(ERR, "failed to allocate memory");
+				goto out;
+			}
+
 			rte_memcpy(&flex_filter_ptr->filter_info,
 				&flex_filter,
 				sizeof(struct rte_eth_flex_filter));
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 3/3] crypto/qat: add null point check and fix mem leak
  2018-01-23  2:44 [PATCH v3 1/3] net/i40e: add null point check and fix mem leak Yong Wang
  2018-01-23  2:44 ` [PATCH v3 2/3] net/e1000: add null point check for rte_zmalloc Yong Wang
@ 2018-01-23  2:45 ` Yong Wang
  2018-01-23 12:16   ` Trahe, Fiona
  2018-01-23 12:16   ` [PATCH v3 3/3] crypto/qat: hebing " Trahe, Fiona
  2018-01-24  8:41 ` [PATCH v3 1/3] net/i40e: " Zhang, Helin
  2 siblings, 2 replies; 7+ messages in thread
From: Yong Wang @ 2018-01-23  2:45 UTC (permalink / raw)
  To: beilei.xing, wenzhuo.lu, fiona.trahe; +Cc: dev, Yong Wang

There are several func calls to rte_zmalloc() which don't do null
point check on the return value. And before return, the memory is not
freed. Fix it by adding null point check and rte_free().

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
v3:
* Rebase on master and modify again.
v2:
* Fix code style warning.
---
 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 0941a58..812dce9 100644
--- a/drivers/crypto/qat/qat_qp.c
+++ b/drivers/crypto/qat/qat_qp.c
@@ -151,6 +151,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;
@@ -192,7 +197,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 =
@@ -217,6 +222,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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 3/3] crypto/qat: add null point check and fix mem leak
  2018-01-23  2:45 ` [PATCH v3 3/3] crypto/qat: add null point check and fix mem leak Yong Wang
@ 2018-01-23 12:16   ` Trahe, Fiona
  2018-01-23 12:16   ` [PATCH v3 3/3] crypto/qat: hebing " Trahe, Fiona
  1 sibling, 0 replies; 7+ messages in thread
From: Trahe, Fiona @ 2018-01-23 12:16 UTC (permalink / raw)
  To: Yong Wang, Xing, Beilei, Lu, Wenzhuo; +Cc: dev, Trahe, Fiona

Hi Yong,

> -----Original Message-----
> From: Yong Wang [mailto:wang.yong19@zte.com.cn]
> Sent: Tuesday, January 23, 2018 2:45 AM
> To: Xing, Beilei <beilei.xing@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>
> Cc: dev@dpdk.org; Yong Wang <wang.yong19@zte.com.cn>
> Subject: [PATCH v3 3/3] crypto/qat: add null point check and fix mem leak
> 
> There are several func calls to rte_zmalloc() which don't do null
> point check on the return value. And before return, the memory is not
> freed. Fix it by adding null point check and rte_free().
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> ---
> v3:
> * Rebase on master and modify again.
> v2:
> * Fix code style warning.
> ---
>  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 0941a58..812dce9 100644
> --- a/drivers/crypto/qat/qat_qp.c
> +++ b/drivers/crypto/qat/qat_qp.c
> @@ -151,6 +151,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;
> @@ -192,7 +197,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 =
> @@ -217,6 +222,7 @@ int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
>  	return 0;
> 
>  create_err:
[Fiona] Thanks for this - it was on my backlog to fix :)
Can you add following too, to cover errors that happen after the rte_mempool_create
	if (qp->op_cookie_pool)
		rte_mempool_free(qp->op_cookie_pool);


> +	rte_free(qp->op_cookies);
>  	rte_free(qp);
>  	return -EFAULT;
>  }
> --
> 1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 3/3] crypto/qat: hebing add null point check and fix mem leak
  2018-01-23  2:45 ` [PATCH v3 3/3] crypto/qat: add null point check and fix mem leak Yong Wang
  2018-01-23 12:16   ` Trahe, Fiona
@ 2018-01-23 12:16   ` Trahe, Fiona
  1 sibling, 0 replies; 7+ messages in thread
From: Trahe, Fiona @ 2018-01-23 12:16 UTC (permalink / raw)
  To: Yong Wang, Xing, Beilei, Lu, Wenzhuo; +Cc: dev, Trahe, Fiona

Hi Yong,

> -----Original Message-----
> From: Yong Wang [mailto:wang.yong19@zte.com.cn]
> Sent: Tuesday, January 23, 2018 2:45 AM
> To: Xing, Beilei <beilei.xing@intel.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>
> Cc: dev@dpdk.org; Yong Wang <wang.yong19@zte.com.cn>
> Subject: [PATCH v8 3/3] crypto/qat: add null point check and fix mem leak
> 
> There are several func calls to rte_zmalloc() which don't do null
> point check on the return value. And before return, the memory is not
> freed. Fix it by adding null point check and rte_free().
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> ---
> v3:
> * Rebase on master and modify again.
> v2:
> * Fix code style warning.
> ---
>  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 0941a58..812dce9 100644
> --- a/drivers/crypto/qat/qat_qp.c
> +++ b/drivers/crypto/qat/qat_qp.c
> @@ -151,6 +151,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;
> @@ -192,7 +197,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 =
> @@ -217,6 +222,7 @@ int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
>  	return 0;
> 
>  create_err:
[Fiona] Thanks for this - it was on my backlog to fix :)
Can you add following too, to cover errors that happen after the rte_mempool_create
	if (qp->op_cookie_pool)
		rte_mempool_free(qp->op_cookie_pool);


> +	rte_free(qp->op_cookies);
>  	rte_free(qp);
>  	return -EFAULT;
>  }
> --
> 1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/3] net/i40e: add null point check and fix mem leak
  2018-01-23  2:44 [PATCH v3 1/3] net/i40e: add null point check and fix mem leak Yong Wang
  2018-01-23  2:44 ` [PATCH v3 2/3] net/e1000: add null point check for rte_zmalloc Yong Wang
  2018-01-23  2:45 ` [PATCH v3 3/3] crypto/qat: add null point check and fix mem leak Yong Wang
@ 2018-01-24  8:41 ` Zhang, Helin
  2018-01-24  9:28   ` 答复: RE: [PATCH v3 1/3] net/i40e: add null point check andfix " wang.yong19
  2 siblings, 1 reply; 7+ messages in thread
From: Zhang, Helin @ 2018-01-24  8:41 UTC (permalink / raw)
  To: Yong Wang, Xing, Beilei, Lu, Wenzhuo, Trahe, Fiona; +Cc: dev

Hi Yong

Thank you so much for your contribution! I have comments in general.
1. for a patch set, you need a cover letter for the series.
2. If a patch is to fix a bug/issue, the title should start with 'fix'.
3. A 'Fixes:' line is needed for any bug fixes.
4. A 'Cc:' line is needed, if the patch should be back ported into any stable release version.
5. you can find some good examples from the 'git log'.

Thanks!

Regards,
Helin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* 答复: RE:  [PATCH v3 1/3] net/i40e: add null point check andfix mem leak
  2018-01-24  8:41 ` [PATCH v3 1/3] net/i40e: " Zhang, Helin
@ 2018-01-24  9:28   ` wang.yong19
  0 siblings, 0 replies; 7+ messages in thread
From: wang.yong19 @ 2018-01-24  9:28 UTC (permalink / raw)
  To: helin.zhang; +Cc: beilei.xing, wenzhuo.lu, fiona.trahe, dev

Hi Helin
Thanks for your advice.
However, it's hard to find the original patches which introduced the bug in general, especailly when the file name has changed.
This may prevent us to contribute to dpdk.
< 4. A 'Cc:' line is needed, if the patch should be back ported into any stable release version.
As a common contributor, I don't know whether the patch should be back ported into any stable release version.
And I have no rights to make this decision.

Thank you!

Yours,
Yong

------------------origin------------------
From: <helin.zhang@intel.com>;
To:<wang.yong19@zte.com.cn>; <beilei.xing@intel.com>; <wenzhuo.lu@intel.com>; <fiona.trahe@intel.com>;
Cc: <dev@dpdk.org>;
Date :2018-01-24 16:41
Subject :RE: [dpdk-dev] [PATCH v3 1/3] net/i40e: add null point check andfix	mem leak
Hi Yong

Thank you so much for your contribution! I have comments in general.
1. for a patch set, you need a cover letter for the series.
2. If a patch is to fix a bug/issue, the title should start with 'fix'.
3. A 'Fixes:' line is needed for any bug fixes.
4. A 'Cc:' line is needed, if the patch should be back ported into any stable release version.
5. you can find some good examples from the 'git log'.

Thanks!

Regards,
Helin

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-01-26  3:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-23  2:44 [PATCH v3 1/3] net/i40e: add null point check and fix mem leak Yong Wang
2018-01-23  2:44 ` [PATCH v3 2/3] net/e1000: add null point check for rte_zmalloc Yong Wang
2018-01-23  2:45 ` [PATCH v3 3/3] crypto/qat: add null point check and fix mem leak Yong Wang
2018-01-23 12:16   ` Trahe, Fiona
2018-01-23 12:16   ` [PATCH v3 3/3] crypto/qat: hebing " Trahe, Fiona
2018-01-24  8:41 ` [PATCH v3 1/3] net/i40e: " Zhang, Helin
2018-01-24  9:28   ` 答复: RE: [PATCH v3 1/3] net/i40e: add null point check andfix " wang.yong19

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.