From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id D94812BE4 for ; Tue, 22 Mar 2016 16:37:49 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 22 Mar 2016 08:37:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,377,1455004800"; d="scan'208";a="673871866" Received: from fooyekan-mobl2.ger.corp.intel.com ([10.252.25.15]) by FMSMGA003.fm.intel.com with SMTP; 22 Mar 2016 08:37:46 -0700 Received: by (sSMTP sendmail emulation); Tue, 22 Mar 2016 15:37:45 +0025 Date: Tue, 22 Mar 2016 15:37:45 +0000 From: Bruce Richardson To: Jiangu Zhao Cc: helin.zhang@intel.com, dev@dpdk.org Message-ID: <20160322153744.GA20448@bricha3-MOBL3> References: <1457946124-17767-1-git-send-email-zhaojg@arraynetworks.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1457946124-17767-1-git-send-email-zhaojg@arraynetworks.com.cn> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] i40e: fix using memory after free issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2016 15:37:50 -0000 On Mon, Mar 14, 2016 at 09:02:04AM +0000, Jiangu Zhao wrote: > The old code still uses entry in the next loop of LIST_FOREACH after free() in i40e_res_pool_destroy(). > Change to a safe way to free entry, which is similar with LIST_FOREACH_SAFE in FreeBSD. > > Signed-off-by: Jiangu Zhao Thanks for the patch. It's missing a "fixes" line as descripted here: http://dpdk.org/doc/guides/contributing/patches.html#commit-messages-body so can you perhaps reply with the id of the commit this is fixing, (or add it into the commit message if you end up doing a V2 of the patch) Helin, can you perhaps review this patch as i40e maintainer. > --- > drivers/net/i40e/i40e_ethdev.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c > index 2f676f6..5af2128 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -3317,17 +3317,21 @@ i40e_res_pool_init (struct i40e_res_pool_info *pool, uint32_t base, > static void > i40e_res_pool_destroy(struct i40e_res_pool_info *pool) > { > - struct pool_entry *entry; > + struct pool_entry *entry, *next_entry; > > if (pool == NULL) > return; > > - LIST_FOREACH(entry, &pool->alloc_list, next) { > + for (entry = LIST_FIRST(&pool->alloc_list); > + entry && (next_entry = LIST_NEXT(entry, next), 1); > + entry = next_entry) { Can we use LIST_FOREACH_SAFE? /Bruce