diff --git a/mm/umm_heap/umm_malloc.c b/mm/umm_heap/umm_malloc.c index 261f0d8460..97a12c2204 100644 --- a/mm/umm_heap/umm_malloc.c +++ b/mm/umm_heap/umm_malloc.c @@ -26,7 +26,7 @@ #include #include - +#include #include #include "umm_heap/umm_heap.h" @@ -57,8 +57,16 @@ FAR void *malloc(size_t size) return memalign(sizeof(FAR void *), size); #else + FAR void *ret; + /* Use mm_malloc() because it implements the clear */ - return mm_malloc(USR_HEAP, size); + ret = mm_malloc(USR_HEAP, size); + if (!ret) + { + set_errno(ENOMEM); + } + + return ret; #endif } diff --git a/mm/umm_heap/umm_memalign.c b/mm/umm_heap/umm_memalign.c index 378ce6e428..f67cfc0cff 100644 --- a/mm/umm_heap/umm_memalign.c +++ b/mm/umm_heap/umm_memalign.c @@ -26,7 +26,7 @@ #include #include - +#include #include #include "umm_heap/umm_heap.h" @@ -86,6 +86,14 @@ FAR void *memalign(size_t alignment, size_t size) return mem; #else - return mm_memalign(USR_HEAP, alignment, size); + FAR void *ret; + + ret = mm_memalign(USR_HEAP, alignment, size); + if (!ret) + { + set_errno(ENOMEM); + } + + return ret; #endif } diff --git a/mm/umm_heap/umm_realloc.c b/mm/umm_heap/umm_realloc.c index 2db289db14..f3c221b528 100644 --- a/mm/umm_heap/umm_realloc.c +++ b/mm/umm_heap/umm_realloc.c @@ -26,7 +26,7 @@ #include #include - +#include #include #include "umm_heap/umm_heap.h" @@ -88,6 +88,14 @@ FAR void *realloc(FAR void *oldmem, size_t size) return mem; #else - return mm_realloc(USR_HEAP, oldmem, size); + FAR void *ret; + + ret = mm_realloc(USR_HEAP, oldmem, size); + if (!ret) + { + set_errno(ENOMEM); + } + + return ret; #endif } diff --git a/mm/umm_heap/umm_zalloc.c b/mm/umm_heap/umm_zalloc.c index 82d0906ae4..0ff400d7fb 100644 --- a/mm/umm_heap/umm_zalloc.c +++ b/mm/umm_heap/umm_zalloc.c @@ -26,7 +26,7 @@ #include #include - +#include #include #include "umm_heap/umm_heap.h" @@ -63,8 +63,16 @@ FAR void *zalloc(size_t size) return mem; #else + FAR void *ret; + /* Use mm_zalloc() because it implements the clear */ - return mm_zalloc(USR_HEAP, size); + ret = mm_zalloc(USR_HEAP, size); + if (!ret) + { + set_errno(ENOMEM); + } + + return ret; #endif }