DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: Zoltan Kiss <zoltan.kiss@schaman.hu>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] memzone: allow full length name
Date: Thu, 21 Jul 2016 15:44:39 +0200	[thread overview]
Message-ID: <5386abeb-0310-a12a-5550-ab6054e9a8e0@6wind.com> (raw)
In-Reply-To: <1469034999-2732-2-git-send-email-zoltan.kiss@schaman.hu>

Hi,

On 07/20/2016 07:16 PM, Zoltan Kiss wrote:
> (strlen(name) == sizeof(mz->name) - 1) is a valid case, change the
> condition to reflect that.
> Move it earlier to avoid lookup with invalid name.
> Change errno to ENAMETOOLONG.
> 
> Fixes: 85cf0079 ("mem: avoid memzone/mempool/ring name truncation")
> 
> Signed-off-by: Zoltan Kiss <zoltan.kiss@schaman.hu>
> ---
>  lib/librte_eal/common/eal_common_memzone.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
> index 5d28341..1bd0a33 100644
> --- a/lib/librte_eal/common/eal_common_memzone.c
> +++ b/lib/librte_eal/common/eal_common_memzone.c
> @@ -144,6 +144,13 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
>  		return NULL;
>  	}
>  
> +	if (strlen(name) > sizeof(mz->name) - 1) {
> +		RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n",
> +			__func__, name);
> +		rte_errno = ENAMETOOLONG;
> +		return NULL;
> +	}
> +
>  	/* zone already exist */
>  	if ((memzone_lookup_thread_unsafe(name)) != NULL) {
>  		RTE_LOG(DEBUG, EAL, "%s(): memzone <%s> already exists\n",
> @@ -152,13 +159,6 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
>  		return NULL;
>  	}
>  
> -	if (strlen(name) >= sizeof(mz->name) - 1) {
> -		RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n",
> -			__func__, name);
> -		rte_errno = EEXIST;
> -		return NULL;
> -	}
> -
>  	/* if alignment is not a power of two */
>  	if (align && !rte_is_power_of_2(align)) {
>  		RTE_LOG(ERR, EAL, "%s(): Invalid alignment: %u\n", __func__,
> 

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Thanks for fixing this.

  reply	other threads:[~2016-07-21 13:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-20 17:16 Zoltan Kiss
2016-07-21 13:44 ` Olivier Matz [this message]
2016-07-21 21:03   ` 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=5386abeb-0310-a12a-5550-ab6054e9a8e0@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=dev@dpdk.org \
    --cc=zoltan.kiss@schaman.hu \
    /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).