diff options
-rw-r--r-- | Kernel/Process.cpp | 16 | ||||
-rw-r--r-- | Kernel/Process.h | 4 | ||||
-rw-r--r-- | Kernel/VM/MemoryManager.cpp | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 2f25867518..cd46574a95 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -193,23 +193,23 @@ Region& Process::allocate_split_region(const Region& source_region, const Range& return region; } -Region* Process::allocate_region(const Range& range, const String& name, int prot, bool commit) +Region* Process::allocate_region(const Range& range, const String& name, int prot, bool should_commit) { ASSERT(range.is_valid()); auto vmobject = AnonymousVMObject::create_with_size(range.size()); - auto& region = add_region(Region::create_user_accessible(range, vmobject, 0, name, prot_to_region_access_flags(prot))); - region.map(page_directory()); - if (commit) - region.commit(); - return ®ion; + auto region = Region::create_user_accessible(range, vmobject, 0, name, prot_to_region_access_flags(prot)); + region->map(page_directory()); + if (should_commit && !region->commit()) + return nullptr; + return &add_region(move(region)); } -Region* Process::allocate_region(VirtualAddress vaddr, size_t size, const String& name, int prot, bool commit) +Region* Process::allocate_region(VirtualAddress vaddr, size_t size, const String& name, int prot, bool should_commit) { auto range = allocate_range(vaddr, size); if (!range.is_valid()) return nullptr; - return allocate_region(range, name, prot, commit); + return allocate_region(range, name, prot, should_commit); } Region* Process::allocate_region_with_vmobject(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const String& name, int prot) diff --git a/Kernel/Process.h b/Kernel/Process.h index f8d5fd265c..ecf3ef1029 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -374,9 +374,9 @@ public: bool is_superuser() const { return m_euid == 0; } Region* allocate_region_with_vmobject(VirtualAddress, size_t, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, const String& name, int prot); - Region* allocate_region(VirtualAddress, size_t, const String& name, int prot = PROT_READ | PROT_WRITE, bool commit = true); + Region* allocate_region(VirtualAddress, size_t, const String& name, int prot = PROT_READ | PROT_WRITE, bool should_commit = true); Region* allocate_region_with_vmobject(const Range&, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, const String& name, int prot); - Region* allocate_region(const Range&, const String& name, int prot = PROT_READ | PROT_WRITE, bool commit = true); + Region* allocate_region(const Range&, const String& name, int prot = PROT_READ | PROT_WRITE, bool should_commit = true); bool deallocate_region(Region& region); Region& allocate_split_region(const Region& source_region, const Range&, size_t offset_in_vmobject); diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index 4257d9f31f..7268a652df 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -358,8 +358,8 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(size_t size, const StringVi auto region = allocate_kernel_region_with_vmobject(range, vmobject, name, access, user_accessible, cacheable); if (!region) return nullptr; - if (should_commit) - region->commit(); + if (should_commit && !region->commit()) + return nullptr; return region; } |