[1/2] net/ice: fix memory leak when releasing vsi

Message ID 9b51e0a97aa6be6c9e64ed4f1e7cc1a2f0553f4d.1595936682.git.wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series fixes for ice driver |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Yunjian Wang July 28, 2020, 1:11 p.m. UTC
  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(-)
  

Patch

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