DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev]  [PATCH 0/2] fixes for ice driver
@ 2020-07-28 13:10 wangyunjian
  2020-07-28 13:11 ` [dpdk-dev] [PATCH 1/2] net/ice: fix memory leak when releasing vsi wangyunjian
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: wangyunjian @ 2020-07-28 13:10 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, qi.z.zhang, jerry.lilijun, xudingke, Yunjian Wang

From: Yunjian Wang <wangyunjian@huawei.com>

This series include two fixes patches for ice driver.

Yunjian Wang (2):
  net/ice: fix memory leak when releasing vsi
  net/ice: fix return value of null not checked

 drivers/net/ice/ice_ethdev.c | 37 +++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

-- 
2.23.0



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

* [dpdk-dev] [PATCH 1/2] net/ice: fix memory leak when releasing vsi
  2020-07-28 13:10 [dpdk-dev] [PATCH 0/2] fixes for ice driver wangyunjian
@ 2020-07-28 13:11 ` wangyunjian
  2020-07-28 13:11 ` [dpdk-dev] [PATCH 2/2] net/ice: fix return value of null not checked wangyunjian
  2020-07-29  0:22 ` [dpdk-dev] [PATCH 0/2] fixes for ice driver Zhang, Qi Z
  2 siblings, 0 replies; 4+ messages in thread
From: wangyunjian @ 2020-07-28 13:11 UTC (permalink / raw)
  To: dev
  Cc: qiming.yang, qi.z.zhang, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

At the end of the vsi release, we should free the 'rss_lut'
and 'rss_key' for the vsi.

Fixes: 50370662b727 ("net/ice: support device and queue ops")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/ice/ice_ethdev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 3534d18ca..5f3882826 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -2280,9 +2280,10 @@ ice_release_vsi(struct ice_vsi *vsi)
 	struct ice_hw *hw;
 	struct ice_vsi_ctx vsi_ctx;
 	enum ice_status ret;
+	int error = 0;
 
 	if (!vsi)
-		return 0;
+		return error;
 
 	hw = ICE_VSI_TO_HW(vsi);
 
@@ -2295,12 +2296,13 @@ ice_release_vsi(struct ice_vsi *vsi)
 	ret = ice_free_vsi(hw, vsi->idx, &vsi_ctx, false, NULL);
 	if (ret != ICE_SUCCESS) {
 		PMD_INIT_LOG(ERR, "Failed to free vsi by aq, %u", vsi->vsi_id);
-		rte_free(vsi);
-		return -1;
+		error = -1;
 	}
 
+	rte_free(vsi->rss_lut);
+	rte_free(vsi->rss_key);
 	rte_free(vsi);
-	return 0;
+	return error;
 }
 
 void
-- 
2.23.0



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

* [dpdk-dev] [PATCH 2/2] net/ice: fix return value of null not checked
  2020-07-28 13:10 [dpdk-dev] [PATCH 0/2] fixes for ice driver wangyunjian
  2020-07-28 13:11 ` [dpdk-dev] [PATCH 1/2] net/ice: fix memory leak when releasing vsi wangyunjian
@ 2020-07-28 13:11 ` wangyunjian
  2020-07-29  0:22 ` [dpdk-dev] [PATCH 0/2] fixes for ice driver Zhang, Qi Z
  2 siblings, 0 replies; 4+ messages in thread
From: wangyunjian @ 2020-07-28 13:11 UTC (permalink / raw)
  To: dev
  Cc: qiming.yang, qi.z.zhang, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

The function rte_zmalloc() could return NULL, the return
value need to be checked.

Fixes: 50370662b727 ("net/ice: support device and queue ops")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/ice/ice_ethdev.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 5f3882826..643dfc6b5 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -2623,13 +2623,24 @@ static int ice_init_rss(struct ice_pf *pf)
 		return 0;
 	}
 
-	if (!vsi->rss_key)
+	if (!vsi->rss_key) {
 		vsi->rss_key = rte_zmalloc(NULL,
 					   vsi->rss_key_size, 0);
-	if (!vsi->rss_lut)
+		if (vsi->rss_key == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to allocate memory for rss_key");
+			return -ENOMEM;
+		}
+	}
+	if (!vsi->rss_lut) {
 		vsi->rss_lut = rte_zmalloc(NULL,
 					   vsi->rss_lut_size, 0);
-
+		if (vsi->rss_lut == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to allocate memory for rss_key");
+			rte_free(vsi->rss_key);
+			vsi->rss_key = NULL;
+			return -ENOMEM;
+		}
+	}
 	/* configure RSS key */
 	if (!rss_conf->rss_key) {
 		/* Calculate the default hash key */
@@ -2643,7 +2654,7 @@ static int ice_init_rss(struct ice_pf *pf)
 	rte_memcpy(key.standard_rss_key, vsi->rss_key, vsi->rss_key_size);
 	ret = ice_aq_set_rss_key(hw, vsi->idx, &key);
 	if (ret)
-		return -EINVAL;
+		goto out;
 
 	/* init RSS LUT table */
 	for (i = 0; i < vsi->rss_lut_size; i++)
@@ -2653,7 +2664,7 @@ static int ice_init_rss(struct ice_pf *pf)
 				 ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF,
 				 vsi->rss_lut, vsi->rss_lut_size);
 	if (ret)
-		return -EINVAL;
+		goto out;
 
 	/* Enable registers for symmetric_toeplitz function. */
 	reg = ICE_READ_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id));
@@ -2665,6 +2676,12 @@ static int ice_init_rss(struct ice_pf *pf)
 	ice_rss_hash_set(pf, rss_conf->rss_hf);
 
 	return 0;
+out:
+	rte_free(vsi->rss_key);
+	vsi->rss_key = NULL;
+	rte_free(vsi->rss_lut);
+	vsi->rss_lut = NULL;
+	return -EINVAL;
 }
 
 static int
-- 
2.23.0



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

* Re: [dpdk-dev] [PATCH 0/2] fixes for ice driver
  2020-07-28 13:10 [dpdk-dev] [PATCH 0/2] fixes for ice driver wangyunjian
  2020-07-28 13:11 ` [dpdk-dev] [PATCH 1/2] net/ice: fix memory leak when releasing vsi wangyunjian
  2020-07-28 13:11 ` [dpdk-dev] [PATCH 2/2] net/ice: fix return value of null not checked wangyunjian
@ 2020-07-29  0:22 ` Zhang, Qi Z
  2 siblings, 0 replies; 4+ messages in thread
From: Zhang, Qi Z @ 2020-07-29  0:22 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: Yang, Qiming, jerry.lilijun, xudingke



> -----Original Message-----
> From: wangyunjian <wangyunjian@huawei.com>
> Sent: Tuesday, July 28, 2020 9:11 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; jerry.lilijun@huawei.com; xudingke@huawei.com;
> Yunjian Wang <wangyunjian@huawei.com>
> Subject: [dpdk-dev] [PATCH 0/2] fixes for ice driver
> 
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> This series include two fixes patches for ice driver.
> 
> Yunjian Wang (2):
>   net/ice: fix memory leak when releasing vsi
>   net/ice: fix return value of null not checked
> 
>  drivers/net/ice/ice_ethdev.c | 37 +++++++++++++++++++++++++++---------
>  1 file changed, 28 insertions(+), 9 deletions(-)
> 
> --
> 2.23.0
> 
Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.
Thanks
Qi


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

end of thread, other threads:[~2020-07-29  0:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 13:10 [dpdk-dev] [PATCH 0/2] fixes for ice driver wangyunjian
2020-07-28 13:11 ` [dpdk-dev] [PATCH 1/2] net/ice: fix memory leak when releasing vsi wangyunjian
2020-07-28 13:11 ` [dpdk-dev] [PATCH 2/2] net/ice: fix return value of null not checked wangyunjian
2020-07-29  0:22 ` [dpdk-dev] [PATCH 0/2] fixes for ice driver Zhang, Qi Z

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