From 68b361bd21bcf7d44dd2fe8d40f4059041b08966 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 16 Sep 2020 18:47:47 +0100 Subject: Kernel: Return ENOMEM in more places There are plenty of places in the kernel that aren't checking if they actually got their allocation. This fixes some of them, but definitely not all. Fixes #3390 Fixes #3391 Also, let's make find_one_free_page() return nullptr if it doesn't get a free index. This stops the kernel crashing when out of memory and allows memory purging to take place again. Fixes #3487 --- Kernel/VM/PhysicalRegion.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Kernel/VM/PhysicalRegion.cpp') diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp index 085d33a01a..84f1e765b0 100644 --- a/Kernel/VM/PhysicalRegion.cpp +++ b/Kernel/VM/PhysicalRegion.cpp @@ -105,7 +105,8 @@ Optional PhysicalRegion::find_one_free_page() return {}; } auto free_index = m_bitmap.find_one_anywhere_unset(m_free_hint); - ASSERT(free_index.has_value()); + if (!free_index.has_value()) + return {}; auto page_index = free_index.value(); m_bitmap.set(page_index, true); -- cgit v1.2.3