summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZoltan Kiss <zoltan.kiss@schaman.hu>2016-07-20 18:16:39 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-07-21 23:05:01 +0200
commit32e17fd571e0139c140674f94a0c3823129af551 (patch)
tree2da837903d53c196e1178cafa4b454964865a282 /lib
parentd23a6bd04d728226c99d6995c8bd65d49d7e61d1 (diff)
downloaddpdk-32e17fd571e0139c140674f94a0c3823129af551.zip
dpdk-32e17fd571e0139c140674f94a0c3823129af551.tar.gz
dpdk-32e17fd571e0139c140674f94a0c3823129af551.tar.xz
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 <zoltan.kiss@schaman.hu> Acked-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_eal/common/eal_common_memzone.c12
1 files changed, 6 insertions, 6 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,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;