summaryrefslogtreecommitdiff
path: root/src/mm/heap.c
diff options
context:
space:
mode:
authorCarlos Maiolino <[email protected]>2025-09-14 14:08:28 +0200
committerCarlos Maiolino <[email protected]>2025-09-14 14:08:28 +0200
commit833f883ab85d57d8f9cfae5a2181b3e097fae8bd (patch)
treede46cae26df1bb6020deff43c680842b08a6cb46 /src/mm/heap.c
parente79687494bc3b01f42a79b0c355533e6e39e9a9d (diff)
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 <[email protected]>
Diffstat (limited to 'src/mm/heap.c')
-rw-r--r--src/mm/heap.c2
1 files changed, 1 insertions, 1 deletions
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);