From a44a0a08cd9d899a2ee601c80d9c36fa3a51123a Mon Sep 17 00:00:00 2001
From: Masayuki Ishikawa <masayuki.ishikawa@gmail.com>
Date: Fri, 11 Feb 2022 15:45:09 +0900
Subject: [PATCH] binfmt: Call umm_initialize() for BUILD_KERNEL & ADDRENV

Summary:
- I noticed that the user heap is not initialized correctly
  if BUILD_KERNEL=y and ADDRENV=y
- This commit fixes this issue

Impact:
- None

Testing:
- Tested with sabre-6quad:netknsh (not merged yet)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
---
 binfmt/binfmt_execmodule.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c
index 503de245c3..8af73eda3a 100644
--- a/binfmt/binfmt_execmodule.c
+++ b/binfmt/binfmt_execmodule.c
@@ -160,6 +160,9 @@ int exec_module(FAR const struct binary_s *binp,
       binfmt_freeargv(argv);
       goto errout_with_tcb;
     }
+
+  binfo("Initialize the user heap (heapsize=%d)\n", binp->addrenv.heapsize);
+  umm_initialize((FAR void *)CONFIG_ARCH_HEAP_VBASE, binp->addrenv.heapsize);
 #endif
 
   /* Note that tcb->flags are not modified.  0=normal task */