mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +00:00
Revert "Kernel: Use an ArmedScopeGuard to revert changes after failed mmap"
This reverts commit 790d620b39
.
This commit is contained in:
parent
3b39e16e8f
commit
03342876b8
1 changed files with 1 additions and 12 deletions
|
@ -5,7 +5,6 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/kmalloc.h>
|
|
||||||
#include <Kernel/Arch/SmapDisabler.h>
|
#include <Kernel/Arch/SmapDisabler.h>
|
||||||
#include <Kernel/Arch/x86/MSR.h>
|
#include <Kernel/Arch/x86/MSR.h>
|
||||||
#include <Kernel/Arch/x86/SafeMem.h>
|
#include <Kernel/Arch/x86/SafeMem.h>
|
||||||
|
@ -185,16 +184,8 @@ ErrorOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> use
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
Memory::Region* region = nullptr;
|
Memory::Region* region = nullptr;
|
||||||
Memory::VirtualRange range { {}, 0 };
|
|
||||||
|
|
||||||
ArmedScopeGuard scope_guard = [&] {
|
auto range = TRY([&]() -> ErrorOr<Memory::VirtualRange> {
|
||||||
if (region)
|
|
||||||
address_space().deallocate_region(*region);
|
|
||||||
else if (range.is_valid())
|
|
||||||
address_space().page_directory().range_allocator().deallocate(range);
|
|
||||||
};
|
|
||||||
|
|
||||||
range = TRY([&]() -> ErrorOr<Memory::VirtualRange> {
|
|
||||||
if (map_randomized)
|
if (map_randomized)
|
||||||
return address_space().page_directory().range_allocator().try_allocate_randomized(rounded_size, alignment);
|
return address_space().page_directory().range_allocator().try_allocate_randomized(rounded_size, alignment);
|
||||||
|
|
||||||
|
@ -257,8 +248,6 @@ ErrorOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> use
|
||||||
|
|
||||||
PerformanceManager::add_mmap_perf_event(*this, *region);
|
PerformanceManager::add_mmap_perf_event(*this, *region);
|
||||||
|
|
||||||
scope_guard.disarm();
|
|
||||||
|
|
||||||
return region->vaddr().get();
|
return region->vaddr().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue