aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/arch/memory/higher_half_mapper.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86_64/arch/memory/higher_half_mapper.cpp b/arch/x86_64/arch/memory/higher_half_mapper.cpp
index ee11d50a..814cc991 100644
--- a/arch/x86_64/arch/memory/higher_half_mapper.cpp
+++ b/arch/x86_64/arch/memory/higher_half_mapper.cpp
@@ -75,6 +75,14 @@ namespace arch::memory
table_path[4 - (level - 1)] = std::pair{next_table, next_index};
}
+ auto [leaf_table, leaf_index] = table_path.back();
+ if (!(*leaf_table)[leaf_index].present())
+ {
+ return std::nullopt;
+ }
+
+ // If execution reaches this point, all page table entries leading to, and including, the leaf entry are present. It
+ // is therefore safe to access their `frame` value without additional checks.
auto release_path = std::views::reverse(table_path);
auto previous_was_empty = true;
auto unmapped_frame = std::optional<kapi::memory::frame>{};