summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordzwdz2023-09-06 21:23:55 +0200
committerdzwdz2023-09-06 21:23:55 +0200
commitcfaf50eac5d649b9206985328ffc118cf1b1bc1e (patch)
tree1de9424883ee70fc73a18bbb97b54381539cbce2
parent59dfa24f6f944ab769b7c6101e2ce386ed5b9579 (diff)
kernel: fix panic with large initrd
-rw-r--r--src/kernel/malloc.c3
1 files changed, 2 insertions, 1 deletions
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);