summaryrefslogtreecommitdiff
path: root/Kernel/VM/PhysicalRegion.cpp
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2020-09-16 18:47:47 +0100
committerAndreas Kling <kling@serenityos.org>2020-09-16 20:38:19 +0200
commit68b361bd21bcf7d44dd2fe8d40f4059041b08966 (patch)
treefe4e6b8decb755197d7eab198240e802b34ca5cc /Kernel/VM/PhysicalRegion.cpp
parent2229b13c974015426cb7889d8ea311e5757099cb (diff)
downloadserenity-68b361bd21bcf7d44dd2fe8d40f4059041b08966.zip
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
Diffstat (limited to 'Kernel/VM/PhysicalRegion.cpp')
-rw-r--r--Kernel/VM/PhysicalRegion.cpp3
1 files changed, 2 insertions, 1 deletions
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<unsigned> 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);