Skip to content

Commit

Permalink
Fix memory alloc bug that caused it to think OOM when it's not.
Browse files Browse the repository at this point in the history
  • Loading branch information
robotman2412 committed Aug 12, 2024
1 parent 33009a6 commit efc6012
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions kernel/src/malloc/static-buddy.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,12 @@ void *buddy_allocate(size_t size, enum block_type type, uint32_t flags) {
break;
}

// NOLINTNEXTLINE
if (size > (1 << allocation_order) - pool->max_order_waste) {
BADGEROS_MALLOC_MSG_WARN("buddy_allocate(" FMT_ZI ") = NULL (Allocation too large)", size);
continue;
if (allocation_order == pool->max_order) {
// NOLINTNEXTLINE
if (size > (1 << allocation_order) - pool->max_order_waste) {
BADGEROS_MALLOC_MSG_WARN("buddy_allocate(" FMT_ZI ") = NULL (Allocation too large)", size);
continue;
}
}

block = pool_find_block(pool, allocation_order, pages);
Expand Down

0 comments on commit efc6012

Please sign in to comment.