patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Wang ShougangX <shougangx.wang@intel.com>
To: dev@dpdk.org
Cc: qiming.yang@intel.com, beilei.xing@intel.com,
	Wang ShougangX <shougangx.wang@intel.com>,
	stable@dpdk.org
Subject: [dpdk-stable] [PATCH v2 4/4] net/ice: fix wild pointer
Date: Thu,  7 Nov 2019 02:22:17 +0000	[thread overview]
Message-ID: <20191107022217.41046-5-shougangx.wang@intel.com> (raw)
In-Reply-To: <20191107022217.41046-1-shougangx.wang@intel.com>

To avoid wild pointer, pointers should be set to NULL after free them.

Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
Fixes: 0f880c3df192 ("net/ice: add flow director counter resource init/release")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 94a6e96df..e6e925b4e 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -165,6 +165,10 @@ ice_fdir_prof_alloc(struct ice_hw *hw)
 		if (!hw->fdir_prof)
 			return -ENOMEM;
 	}
+
+	/* To avoid wild pointer, unused field pointer should be NULL */
+	hw->fdir_prof[ICE_FLTR_PTYPE_NONF_NONE] = NULL;
+
 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     ptype < ICE_FLTR_PTYPE_MAX;
 	     ptype++) {
@@ -180,9 +184,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw)
 fail_mem:
 	for (fltr_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     fltr_ptype < ptype;
-	     fltr_ptype++)
+	     fltr_ptype++) {
 		rte_free(hw->fdir_prof[fltr_ptype]);
+		hw->fdir_prof[fltr_ptype] = NULL;
+	}
+
 	rte_free(hw->fdir_prof);
+	hw->fdir_prof = NULL;
 	return -ENOMEM;
 }
 
@@ -262,8 +270,10 @@ ice_fdir_counter_release(struct ice_pf *pf)
 				&fdir_info->counter;
 	uint8_t i;
 
-	for (i = 0; i < container->index_free; i++)
+	for (i = 0; i < container->index_free; i++) {
 		rte_free(container->pools[i]);
+		container->pools[i] = NULL;
+	}
 
 	TAILQ_INIT(&container->pool_list);
 	container->index_free = 0;
@@ -412,6 +422,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
 		rte_free(fdir_info->hash_map);
 	if (fdir_info->hash_table)
 		rte_hash_free(fdir_info->hash_table);
+
+	fdir_info->hash_map = NULL;
+	fdir_info->hash_table = NULL;
 }
 
 /*
@@ -538,10 +551,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
 
 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     ptype < ICE_FLTR_PTYPE_MAX;
-	     ptype++)
+	     ptype++) {
 		rte_free(hw->fdir_prof[ptype]);
+		hw->fdir_prof[ptype] = NULL;
+	}
 
 	rte_free(hw->fdir_prof);
+	hw->fdir_prof = NULL;
 }
 
 /* Remove a profile for some filter type */
-- 
2.17.1


  parent reply	other threads:[~2019-11-07  8:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05  3:38 [dpdk-stable] [PATCH] " Wang ShougangX
     [not found] ` <20191107022217.41046-1-shougangx.wang@intel.com>
2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 1/4] net/ice: fix memzone reserve and release in FDIR Wang ShougangX
2019-11-11  8:09     ` [dpdk-stable] [dpdk-dev] " Ye Xiaolong
2019-11-11  8:39       ` Wang, ShougangX
2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
2019-11-07  2:22   ` [dpdk-stable] [PATCH v2 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
2019-11-07  2:22   ` Wang ShougangX [this message]
2019-11-07  3:19 ` [dpdk-stable] [dpdk-dev] [PATCH] net/ice: fix wild pointer Ye Xiaolong
2019-11-07  3:30   ` Ye Xiaolong
2019-11-07  5:44     ` Wang, ShougangX

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=20191107022217.41046-5-shougangx.wang@intel.com \
    --to=shougangx.wang@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=qiming.yang@intel.com \
    --cc=stable@dpdk.org \
    /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).