aboutsummaryrefslogtreecommitdiff
path: root/sys/vm
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2023-12-25 23:27:56 -0500
committerIan Moffett <ian@osmora.org>2023-12-25 23:27:56 -0500
commitb99fe991c30280b99f68ea469d743f2d66d09c49 (patch)
tree978b11f4d04cc957dc936e7be0fa76cabddb9649 /sys/vm
parent7383e73f4b43b914b766d3d1688e1ba96b9712a0 (diff)
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 <ian@osmora.org>
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_physseg.c10
1 files changed, 5 insertions, 5 deletions
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;