From: Zoltan Kiss Date: Wed, 20 Jul 2016 17:16:39 +0000 (+0100) Subject: mem: allow full length name X-Git-Tag: spdx-start~6133 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=32e17fd571e0139c140674f94a0c3823129af551;p=dpdk.git mem: allow full length name (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 Acked-by: Olivier Matz --- diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index 5d28341f7e..1bd0a33d1d 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -144,16 +144,16 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, return NULL; } - /* zone already exist */ - if ((memzone_lookup_thread_unsafe(name)) != NULL) { - RTE_LOG(DEBUG, EAL, "%s(): memzone <%s> already exists\n", + if (strlen(name) > sizeof(mz->name) - 1) { + RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n", __func__, name); - rte_errno = EEXIST; + rte_errno = ENAMETOOLONG; return NULL; } - if (strlen(name) >= sizeof(mz->name) - 1) { - RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n", + /* zone already exist */ + if ((memzone_lookup_thread_unsafe(name)) != NULL) { + RTE_LOG(DEBUG, EAL, "%s(): memzone <%s> already exists\n", __func__, name); rte_errno = EEXIST; return NULL;