]> xenbits.xensource.com Git - unikraft/libs/libgo.git/commitdiff
Fix error handling with uk_posix_memalign()
authorSimon Kuenzer <simon.kuenzer@neclab.eu>
Sat, 8 Feb 2020 10:47:14 +0000 (11:47 +0100)
committerSimon Kuenzer <simon.kuenzer@neclab.eu>
Sat, 8 Feb 2020 16:43:19 +0000 (17:43 +0100)
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 <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
glue.c

diff --git a/glue.c b/glue.c
index d8dd695b5943064150681b175ae7a2a3a836c682..301b0db559e49ce796b58247d7bcca91884b3521 100644 (file)
--- 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;
 }