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 at 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 at 6wind.com> Thanks for fixing this.