From aa662bdcac9c826a724ad2c102c82574de7c2c12 Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Tue, 8 Jul 2025 13:15:14 +0200 Subject: [PATCH] fix: prevent virtual heap for multiple initialization this is a fix for 38c4810513bbd4c04e77ddb093aa51a859a433df It may happen that virtual_heap_init would be called several times. This commit prevents the heap for being re-initialized Signed-off-by: Marcin Szkudlinski --- zephyr/lib/alloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index 41d80aa9342a..b0d4443b08b6 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -289,7 +289,9 @@ static const struct vmh_heap_config static_hp_buffers = { static int virtual_heap_init(void) { - virtual_buffers_heap = vmh_init_heap(&static_hp_buffers, false); + if (!virtual_buffers_heap) + virtual_buffers_heap = vmh_init_heap(&static_hp_buffers, false); + if (!virtual_buffers_heap) { tr_err(&zephyr_tr, "Unable to init virtual heap"); return -ENOMEM;