DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: Thomas Monjalon <thomas.monjalon@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2] mempool: fix unsafe removal from list by callback
Date: Mon, 25 Jul 2016 22:09:25 +0200	[thread overview]
Message-ID: <72f68706-51c1-693c-cb66-7824be2baeba@6wind.com> (raw)
In-Reply-To: <1469476476-2148-1-git-send-email-thomas.monjalon@6wind.com>

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 <sergio.gonzalez.monroy@intel.com>
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> ---
>  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 <olivier.matz@6wind.com>

Thanks

  reply	other threads:[~2016-07-25 20:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-22 16:01 [dpdk-dev] [PATCH 1/2] eal: add stailq safe iterator macro Sergio Gonzalez Monroy
2016-07-22 16:01 ` [dpdk-dev] [PATCH 2/2] mempool: fix unsafe tailq element removal Sergio Gonzalez Monroy
2016-07-25 16:30   ` Olivier Matz
2016-07-25 19:54     ` [dpdk-dev] [PATCH v2] mempool: fix unsafe removal from list by callback Thomas Monjalon
2016-07-25 20:09       ` Olivier Matz [this message]
2016-07-25 20:21         ` Thomas Monjalon
2016-07-22 16:16 ` [dpdk-dev] [PATCH 1/2] eal: add stailq safe iterator macro Thomas Monjalon

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=72f68706-51c1-693c-cb66-7824be2baeba@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.com \
    /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).