From: Simon Kuenzer Date: Sat, 8 Feb 2020 10:47:14 +0000 (+0100) Subject: Fix error handling with uk_posix_memalign() X-Git-Tag: RELEASE-0.4~1 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d8d97e7d02448153ee98510468f5ce8e7ab54f7a;p=unikraft%2Flibs%2Flibgo.git Fix error handling with uk_posix_memalign() In the cases of failed allocation, `uk_posix_memalign()` is returning an errno number but does not change `memptr`. Instead of checking `memptr` being NULL, we test failures with `uk_posix_memalign()`'s return codes. Signed-off-by: Simon Kuenzer Reviewed-by: Felipe Huici --- diff --git a/glue.c b/glue.c index d8dd695..301b0db 100644 --- a/glue.c +++ b/glue.c @@ -296,9 +296,8 @@ void *alloc_stack() struct uk_sched *sched = uk_sched_get_default(); void *stack; - uk_posix_memalign(sched->allocator, - &stack, __STACK_SIZE, __STACK_SIZE); - if (stack == NULL) + if (uk_posix_memalign(sched->allocator, &stack, + __STACK_SIZE, __STACK_SIZE) != 0) printf("error allocating stack\n"); return stack; }