DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] memzone: allow full length name
@ 2016-07-20 17:16 Zoltan Kiss
  2016-07-21 13:44 ` Olivier Matz
  0 siblings, 1 reply; 3+ messages in thread
From: Zoltan Kiss @ 2016-07-20 17:16 UTC (permalink / raw)
  To: dev; +Cc: olivier.matz

(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__,
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] memzone: allow full length name
  2016-07-20 17:16 [dpdk-dev] [PATCH] memzone: allow full length name Zoltan Kiss
@ 2016-07-21 13:44 ` Olivier Matz
  2016-07-21 21:03   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier Matz @ 2016-07-21 13:44 UTC (permalink / raw)
  To: Zoltan Kiss, dev

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] memzone: allow full length name
  2016-07-21 13:44 ` Olivier Matz
@ 2016-07-21 21:03   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2016-07-21 21:03 UTC (permalink / raw)
  To: Zoltan Kiss; +Cc: dev, Olivier Matz

> > (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>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-21 21:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-20 17:16 [dpdk-dev] [PATCH] memzone: allow full length name Zoltan Kiss
2016-07-21 13:44 ` Olivier Matz
2016-07-21 21:03   ` Thomas Monjalon

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).