From 4419685b7e6d78306c6d1e31402c20822fbfb610 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 28 Apr 2020 16:25:04 +0200 Subject: [PATCH] Kernel: Leave VMObject alone on OOM during CoW fault If we OOM during a CoW fault and fail to allocate a new page for the writing process, just leave the original VMObject alone so everyone else can keep using it. --- Kernel/VM/Region.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index d092239140..4bed703219 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -397,12 +397,12 @@ PageFaultResponse Region::handle_cow_fault(size_t page_index_in_region) #ifdef PAGE_FAULT_DEBUG dbg() << " >> It's a COW page and it's time to COW!"; #endif - auto physical_page_to_copy = move(page_slot); auto page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::No); if (page.is_null()) { klog() << "MM: handle_cow_fault was unable to allocate a physical page"; return PageFaultResponse::ShouldCrash; } + auto physical_page_to_copy = move(page_slot); u8* dest_ptr = MM.quickmap_page(*page); const u8* src_ptr = vaddr().offset(page_index_in_region * PAGE_SIZE).as_ptr(); #ifdef PAGE_FAULT_DEBUG