memblock: fix bounds being ignored when iterating through total or reserved regions

This commit is contained in:
2023-12-30 15:29:13 +00:00
parent b0c021d4e9
commit abfd97b924

View File

@@ -311,7 +311,10 @@ int memblock_free_phys(phys_addr_t addr, size_t size)
return 0;
}
void __next_memory_region(struct memblock_iter *it, struct memblock_type *type_a, struct memblock_type *type_b, uintptr_t start, uintptr_t end)
void __next_memory_region(
struct memblock_iter *it,
struct memblock_type *type_a, struct memblock_type *type_b,
uintptr_t start, uintptr_t end)
{
unsigned int idx_a = IDX_A(it->__idx);
unsigned int idx_b = IDX_B(it->__idx);
@@ -323,10 +326,14 @@ void __next_memory_region(struct memblock_iter *it, struct memblock_type *type_a
uintptr_t m_end = m->limit;
if (!type_b) {
it->it_base = m->base;
it->it_limit = m->limit;
it->it_base = MAX(m->base, start);
it->it_limit = MIN(m->limit, end);
it->it_status = m->status;
if (it->it_base >= it->it_limit) {
continue;
}
it->__idx = ITER(idx_a + 1, idx_b);
return;
}