From 5cf3814d9bc7a7e6c4aeadbe446f0a8cfbf9244b Mon Sep 17 00:00:00 2001 From: Tonghao Zhang Date: Thu, 11 May 2017 23:03:43 -0700 Subject: [PATCH] memzone: check NUMA id when reserving a zone If the socket_id is invalid (e.g. -2, -3), the memzone_reserve_aligned_thread_unsafe should return the EINVAL and not ENOMEM. To avoid it, we should check the socket_id before calling malloc_heap_alloc. Signed-off-by: Tonghao Zhang Acked-by: Bruce Richardson --- lib/librte_eal/common/eal_common_memzone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index 64f4e0ade4..3026e36b8d 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -189,7 +189,8 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, return NULL; } - if ((socket_id != SOCKET_ID_ANY) && (socket_id >= RTE_MAX_NUMA_NODES)) { + if ((socket_id != SOCKET_ID_ANY) && + (socket_id >= RTE_MAX_NUMA_NODES || socket_id < 0)) { rte_errno = EINVAL; return NULL; } -- 2.20.1