mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Kernel: Make AddressSpace::find_regions_intersecting OOM-fallible
This commit is contained in:
parent
dab73d6d23
commit
a6f0ab358a
|
@ -81,7 +81,7 @@ ErrorOr<void> AddressSpace::unmap_mmap_range(VirtualAddress addr, size_t size)
|
|||
}
|
||||
|
||||
// Try again while checking multiple regions at a time.
|
||||
auto const& regions = find_regions_intersecting(range_to_unmap);
|
||||
auto const& regions = TRY(find_regions_intersecting(range_to_unmap));
|
||||
if (regions.is_empty())
|
||||
return {};
|
||||
|
||||
|
@ -237,7 +237,7 @@ Region* AddressSpace::find_region_containing(VirtualRange const& range)
|
|||
return (*candidate)->range().contains(range) ? candidate->ptr() : nullptr;
|
||||
}
|
||||
|
||||
Vector<Region*> AddressSpace::find_regions_intersecting(VirtualRange const& range)
|
||||
ErrorOr<Vector<Region*>> AddressSpace::find_regions_intersecting(VirtualRange const& range)
|
||||
{
|
||||
Vector<Region*> regions = {};
|
||||
size_t total_size_collected = 0;
|
||||
|
@ -250,7 +250,7 @@ Vector<Region*> AddressSpace::find_regions_intersecting(VirtualRange const& rang
|
|||
for (auto iter = m_regions.begin_from((*found_region)->vaddr().get()); !iter.is_end(); ++iter) {
|
||||
const auto& iter_range = (*iter)->range();
|
||||
if (iter_range.base() < range.end() && iter_range.end() > range.base()) {
|
||||
regions.append(*iter);
|
||||
TRY(regions.try_append(*iter));
|
||||
|
||||
total_size_collected += (*iter)->size() - iter_range.intersect(range).size();
|
||||
if (total_size_collected == range.size())
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
Region* find_region_from_range(VirtualRange const&);
|
||||
Region* find_region_containing(VirtualRange const&);
|
||||
|
||||
Vector<Region*> find_regions_intersecting(VirtualRange const&);
|
||||
ErrorOr<Vector<Region*>> find_regions_intersecting(VirtualRange const&);
|
||||
|
||||
bool enforces_syscall_regions() const { return m_enforces_syscall_regions; }
|
||||
void set_enforces_syscall_regions(bool b) { m_enforces_syscall_regions = b; }
|
||||
|
|
|
@ -323,7 +323,7 @@ ErrorOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int p
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (const auto& regions = address_space().find_regions_intersecting(range_to_mprotect); regions.size()) {
|
||||
if (const auto& regions = TRY(address_space().find_regions_intersecting(range_to_mprotect)); regions.size()) {
|
||||
size_t full_size_found = 0;
|
||||
// Check that all intersecting regions are compatible.
|
||||
for (const auto* region : regions) {
|
||||
|
|
|
@ -189,7 +189,7 @@ ErrorOr<void> Process::remap_range_as_stack(FlatPtr address, size_t size)
|
|||
return {};
|
||||
}
|
||||
|
||||
if (const auto& regions = address_space().find_regions_intersecting(range_to_remap); regions.size()) {
|
||||
if (const auto& regions = TRY(address_space().find_regions_intersecting(range_to_remap)); regions.size()) {
|
||||
size_t full_size_found = 0;
|
||||
// Check that all intersecting regions are compatible.
|
||||
for (const auto* region : regions) {
|
||||
|
|
Loading…
Reference in a new issue