diff options
| author | Carlos Maiolino <[email protected]> | 2025-09-14 14:08:28 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-09-14 14:08:28 +0200 |
| commit | 833f883ab85d57d8f9cfae5a2181b3e097fae8bd (patch) | |
| tree | de46cae26df1bb6020deff43c680842b08a6cb46 | |
| parent | e79687494bc3b01f42a79b0c355533e6e39e9a9d (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]>
| -rw-r--r-- | src/mm/heap.c | 2 |
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); |
