From cfaf50eac5d649b9206985328ffc118cf1b1bc1e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 6 Sep 2023 21:23:55 +0200 Subject: kernel: fix panic with large initrd --- src/kernel/malloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/kernel/malloc.c b/src/kernel/malloc.c index 0cfcc68..409a487 100644 --- a/src/kernel/malloc.c +++ b/src/kernel/malloc.c @@ -59,7 +59,8 @@ void mem_reserve(void *addr, size_t len) { len += off; size_t first = ((uintptr_t)addr - (uintptr_t)pbitmap_start) / PAGE_SIZE; for (size_t i = 0; i * PAGE_SIZE < len; i++) { - if (first + i >= pbitmap_len) break; + if ((first + i) / 8 >= pbitmap_len) + break; if (bitmap_get(first + i)) panic_invalid_state(); bitmap_set(first + i, true); -- cgit v1.2.3