From b99fe991c30280b99f68ea469d743f2d66d09c49 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 25 Dec 2023 23:27:56 -0500 Subject: kernel: vm_physseg: Fix allocation issue We should check free_count before possibly resetting it. We don't want horrible things to happen. Signed-off-by: Ian Moffett --- sys/vm/vm_physseg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sys') diff --git a/sys/vm/vm_physseg.c b/sys/vm/vm_physseg.c index d9abc4b..1675649 100644 --- a/sys/vm/vm_physseg.c +++ b/sys/vm/vm_physseg.c @@ -184,6 +184,11 @@ vm_alloc_pageframe_internal(size_t count) uintptr_t frame_idx = 0; /* The base index of first free frame */ for (size_t i = last_used_idx; i < bitmap_size*8; ++i) { + if (free_count == count) { + can_alloc = true; + break; + } + is_free = !bitmap_test_bit(bitmap, i); if (!is_free) { @@ -191,11 +196,6 @@ vm_alloc_pageframe_internal(size_t count) continue; } - if (free_count == count) { - can_alloc = true; - break; - } - /* Assume free here */ if (frame_idx == 0) frame_idx = i; -- cgit v1.2.3