From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id E3BBB5594 for ; Mon, 25 Jul 2016 22:09:31 +0200 (CEST) Received: from alille-653-1-523-220.w90-58.abo.wanadoo.fr ([90.58.223.220] helo=[192.168.1.13]) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bRmET-0003ym-RN; Mon, 25 Jul 2016 22:12:10 +0200 To: Thomas Monjalon References: <1469476476-2148-1-git-send-email-thomas.monjalon@6wind.com> Cc: dev@dpdk.org From: Olivier Matz Message-ID: <72f68706-51c1-693c-cb66-7824be2baeba@6wind.com> Date: Mon, 25 Jul 2016 22:09:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: <1469476476-2148-1-git-send-email-thomas.monjalon@6wind.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] mempool: fix unsafe removal from list by callback 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: Mon, 25 Jul 2016 20:09:32 -0000 Hello Thomas, On 07/25/2016 09:54 PM, Thomas Monjalon wrote: > If a mempool is removed from the list by a callback function > during rte_mempool_walk(), the TAILQ_FOREACH loop will fail unexpectedly. > It is fixed by using the safe version of the loop macro. > > Reported-by: Sergio Gonzalez Monroy > Signed-off-by: Thomas Monjalon > --- > lib/librte_mempool/rte_mempool.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > index 8806633..2e28e2e 100644 > --- a/lib/librte_mempool/rte_mempool.c > +++ b/lib/librte_mempool/rte_mempool.c > @@ -1283,12 +1283,13 @@ void rte_mempool_walk(void (*func)(struct rte_mempool *, void *), > { > struct rte_tailq_entry *te = NULL; > struct rte_mempool_list *mempool_list; > + void *tmp_te; > > mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list); > > rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK); > > - TAILQ_FOREACH(te, mempool_list, next) { > + TAILQ_FOREACH_SAFE(te, mempool_list, next, tmp_te) { > (*func)((struct rte_mempool *) te->data, arg); > } > > Acked-by: Olivier Matz Thanks