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 02E7EA04B8; Tue, 12 Nov 2019 08:39:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C9B05CF3; Tue, 12 Nov 2019 08:39:13 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 51205A69 for ; Tue, 12 Nov 2019 08:39:12 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Nov 2019 23:39:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,295,1569308400"; d="scan'208";a="355029803" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 11 Nov 2019 23:39:10 -0800 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 Nov 2019 23:39:08 -0800 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 Nov 2019 23:39:08 -0800 Received: from shsmsx105.ccr.corp.intel.com ([169.254.11.225]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.41]) with mapi id 14.03.0439.000; Tue, 12 Nov 2019 15:39:07 +0800 From: "Zhang, Qi Z" To: "Wang, ShougangX" , "dev@dpdk.org" CC: "Wang, ShougangX" Thread-Topic: [dpdk-dev] [PATCH v3 4/4] net/ice: fix wild pointer Thread-Index: AQHVmST2Lzhu32YaG0yjXhgqzI1PY6eHJXVA Date: Tue, 12 Nov 2019 07:39:05 +0000 Message-ID: <039ED4275CED7440929022BC67E7061153DC82CA@SHSMSX105.ccr.corp.intel.com> References: <20191107022217.41046-1-shougangx.wang@intel.com> <20191112002701.30658-1-shougangx.wang@intel.com> <20191112002701.30658-5-shougangx.wang@intel.com> In-Reply-To: <20191112002701.30658-5-shougangx.wang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjQ2NDYzMDEtZjdkYS00OGQwLWJkYmUtODQ5Mjk4YmQ3YmQxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSm5WZGVqU2NuR2xva2p5MW9LZk5UVjdsZGxDcWlsdldOK3lVaSsxc29KaGJyQUFvZFVhNjFXeEc4RnNBUXFnaSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3 4/4] net/ice: fix wild pointer X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: dev On Behalf Of Wang ShougangX > Sent: Tuesday, November 12, 2019 8:27 AM > To: dev@dpdk.org > Cc: Wang, ShougangX > Subject: [dpdk-dev] [PATCH v3 4/4] net/ice: fix wild pointer >=20 > To avoid wild pointer, pointers should be set to NULL after free them. >=20 > 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/re= lease") >=20 > Signed-off-by: Wang ShougangX > --- > drivers/net/ice/ice_fdir_filter.c | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir= _filter.c > index 361969f71..78754f365 100644 > --- a/drivers/net/ice/ice_fdir_filter.c > +++ b/drivers/net/ice/ice_fdir_filter.c > @@ -152,6 +152,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] =3D NULL; This is not necessary, since ice_malloc already guarantee all the allocated= memory is init to 0 > + > for (ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_UDP; > ptype < ICE_FLTR_PTYPE_MAX; > ptype++) { > @@ -167,9 +171,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw) > fail_mem: > for (fltr_ptype =3D 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] =3D NULL; > + } > + > rte_free(hw->fdir_prof); > + hw->fdir_prof =3D NULL; > return -ENOMEM; > } >=20 > @@ -249,8 +257,10 @@ ice_fdir_counter_release(struct ice_pf *pf) > &fdir_info->counter; > uint8_t i; >=20 > - for (i =3D 0; i < container->index_free; i++) > + for (i =3D 0; i < container->index_free; i++) { > rte_free(container->pools[i]); > + container->pools[i] =3D NULL; > + } >=20 > TAILQ_INIT(&container->pool_list); > container->index_free =3D 0; > @@ -400,6 +410,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 =3D NULL; > + fdir_info->hash_table =3D NULL; > } >=20 > /* > @@ -526,10 +539,13 @@ ice_fdir_prof_free(struct ice_hw *hw) >=20 > for (ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_UDP; > ptype < ICE_FLTR_PTYPE_MAX; > - ptype++) > + ptype++) { > rte_free(hw->fdir_prof[ptype]); > + hw->fdir_prof[ptype] =3D NULL; > + } >=20 > rte_free(hw->fdir_prof); > + hw->fdir_prof =3D NULL; > } >=20 > /* Remove a profile for some filter type */ > -- > 2.17.1