From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: [PATCH 2/2] mem: fix initialization check for malloc heap Date: Tue, 15 Apr 2014 15:50:59 +0200 Message-ID: <1397569859-14460-2-git-send-email-david.marchand@6wind.com> References: <1397569859-14460-1-git-send-email-david.marchand@6wind.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1397569859-14460-1-git-send-email-david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" From: Didier Pallard initialised field must be checked against INITIALISED value before allowing malloc to occur, else some core may pass the test and start malloc while heap is in INITIALISING state and is not fully initialized. Signed-off-by: Didier Pallard --- lib/librte_malloc/malloc_heap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_malloc/malloc_heap.c b/lib/librte_malloc/malloc_heap.c index 64668cb..eed8a63 100644 --- a/lib/librte_malloc/malloc_heap.c +++ b/lib/librte_malloc/malloc_heap.c @@ -197,7 +197,7 @@ void * malloc_heap_alloc(struct malloc_heap *heap, const char *type __attribute__((unused)), size_t size, unsigned align) { - if (!heap->initialised) + if (heap->initialised != INITIALISED) malloc_heap_init(heap); size = CACHE_LINE_ROUNDUP(size); @@ -227,7 +227,7 @@ int malloc_heap_get_stats(const struct malloc_heap *heap, struct rte_malloc_socket_stats *socket_stats) { - if (!heap->initialised) + if (heap->initialised != INITIALISED) return -1; struct malloc_elem *elem = heap->free_head; -- 1.7.10.4