Return from rte_socket_id_by_idx() may be negative, which would result in negative array index.
Coverity issue: 272590 Fixes: 1403f87d4fb8 ("malloc: enable memory hotplug support") Cc: anatoly.bura...@intel.com Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com> --- lib/librte_eal/common/malloc_heap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c index 5cf7231..f81aaf3 100644 --- a/lib/librte_eal/common/malloc_heap.c +++ b/lib/librte_eal/common/malloc_heap.c @@ -563,6 +563,10 @@ malloc_heap_alloc(const char *type, size_t size, int socket_arg, /* try other heaps */ for (i = 0; i < (int) rte_socket_count(); i++) { cur_socket = rte_socket_id_by_idx(i); + if (cur_socket < 0) { + RTE_LOG(ERR, EAL, "Invalid socket index: %i\n", i); + continue; + } if (cur_socket == socket) continue; ret = heap_alloc_on_socket(type, size, cur_socket, flags, -- 2.7.4