From 833f883ab85d57d8f9cfae5a2181b3e097fae8bd Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sun, 14 Sep 2025 14:08:28 +0200 Subject: heap_malloc_pages should check for a negative value The first heap page (0x0) is a valid and usable page for now. When checking the starting page from heap_get_start_page(), we need to take that into account, otherwise we'll always return the first 0x0 page as the allocated page. This makes the users to always get 0x0 as the allocated region. We loose the possibility for error checking here, so we'll need to rework this API so we can get an error check. Signed-off-by: Carlos Maiolino --- src/mm/heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mm') diff --git a/src/mm/heap.c b/src/mm/heap.c index 6254bbc..e0b7208 100644 --- a/src/mm/heap.c +++ b/src/mm/heap.c @@ -149,7 +149,7 @@ heap_malloc_pages(struct heap *heap, uint32_t pages) uint32_t start_page = heap_get_start_page(heap, pages); - if (!start_page) + if (start_page < 0) goto out; addr = heap_page_to_addr(heap, start_page); -- cgit v1.2.3