Boundary check in early_alloc_pages()

This commit is contained in:
Masamichi Takagi
2017-03-04 15:10:39 +09:00
parent da4a5ec44b
commit 1076010de4
2 changed files with 7 additions and 1 deletions

View File

@ -45,7 +45,11 @@ void *early_alloc_pages(int nr_pages)
last_page = phys_to_virt(virt_to_phys(last_page));
} else if (last_page == (void *)-1) {
panic("Early allocator is already finalized. Do not use it.\n");
}
} else {
if(virt_to_phys(last_page) >= bootstrap_mem_end) {
panic("Early allocator: Out of memory\n");
}
}
p = last_page;
last_page += (nr_pages * PAGE_SIZE);

View File

@ -34,6 +34,8 @@ enum ihk_mc_gma_type {
IHK_MC_RESERVED_AREA_END,
};
extern unsigned long bootstrap_mem_end;
enum ihk_mc_ma_type {
IHK_MC_MA_AVAILABLE,
IHK_MC_MA_RESERVED,