From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B1682A034E for ; Thu, 7 Nov 2019 09:54:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A33C1E973; Thu, 7 Nov 2019 09:54:09 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E8B221E979; Thu, 7 Nov 2019 09:54:07 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 00:54:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,277,1569308400"; d="scan'208";a="212977182" Received: from intel.sh.intel.com ([10.239.255.146]) by fmsmga001.fm.intel.com with ESMTP; 07 Nov 2019 00:54:06 -0800 From: Wang ShougangX To: dev@dpdk.org Cc: qiming.yang@intel.com, beilei.xing@intel.com, Wang ShougangX , stable@dpdk.org Date: Thu, 7 Nov 2019 02:22:17 +0000 Message-Id: <20191107022217.41046-5-shougangx.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107022217.41046-1-shougangx.wang@intel.com> References: <20191105033806.2878-1-shougangx.wang@intel.com> <20191107022217.41046-1-shougangx.wang@intel.com> Subject: [dpdk-stable] [PATCH v2 4/4] net/ice: fix wild pointer X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- 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