patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH 1/2] net/ice: fix memory leak when releasing vsi
       [not found] <cover.1595936682.git.wangyunjian@huawei.com>
@ 2020-07-28 13:11 ` wangyunjian
  2020-07-28 13:11 ` [dpdk-stable] [dpdk-dev] [PATCH 2/2] net/ice: fix return value of null not checked wangyunjian
  1 sibling, 0 replies; 2+ 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] 2+ messages in thread

* [dpdk-stable] [dpdk-dev] [PATCH 2/2] net/ice: fix return value of null not checked
       [not found] <cover.1595936682.git.wangyunjian@huawei.com>
  2020-07-28 13:11 ` [dpdk-stable] [dpdk-dev] [PATCH 1/2] net/ice: fix memory leak when releasing vsi wangyunjian
@ 2020-07-28 13:11 ` wangyunjian
  1 sibling, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2020-07-28 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1595936682.git.wangyunjian@huawei.com>
2020-07-28 13:11 ` [dpdk-stable] [dpdk-dev] [PATCH 1/2] net/ice: fix memory leak when releasing vsi wangyunjian
2020-07-28 13:11 ` [dpdk-stable] [dpdk-dev] [PATCH 2/2] net/ice: fix return value of null not checked wangyunjian

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