If a free memory region is too small for the current requested
allocation, skip to the next region directly.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1449
UK_ASSERT_VALID_FREE_MRD(mrd);
UK_ASSERT(mrd->pbase <= __U64_MAX - size);
- pstart = ALIGN_UP(mrd->pbase, __PAGE_SIZE);
- pend = pstart + size;
-
if ((mrd->flags & UKPLAT_MEMRF_PERMS) !=
(UKPLAT_MEMRF_READ | UKPLAT_MEMRF_WRITE))
return NULL;
- ostart = mrd->pbase;
olen = mrd->len;
+ if (olen < size)
+ continue;
+
+ ostart = mrd->pbase;
+ pstart = ALIGN_UP(mrd->pbase, __PAGE_SIZE);
+ pend = pstart + size;
/* If fragmenting this memory region leaves it with length 0,
* then simply overwrite and return it instead.