memblock: fix bounds being ignored when iterating through total or reserved regions
This commit is contained in:
@@ -311,7 +311,10 @@ int memblock_free_phys(phys_addr_t addr, size_t size)
|
|||||||
return 0;
|
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_a = IDX_A(it->__idx);
|
||||||
unsigned int idx_b = IDX_B(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;
|
uintptr_t m_end = m->limit;
|
||||||
|
|
||||||
if (!type_b) {
|
if (!type_b) {
|
||||||
it->it_base = m->base;
|
it->it_base = MAX(m->base, start);
|
||||||
it->it_limit = m->limit;
|
it->it_limit = MIN(m->limit, end);
|
||||||
it->it_status = m->status;
|
it->it_status = m->status;
|
||||||
|
|
||||||
|
if (it->it_base >= it->it_limit) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
it->__idx = ITER(idx_a + 1, idx_b);
|
it->__idx = ITER(idx_a + 1, idx_b);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user