mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
core: avoid freeing wrong regions during attach
In case of an Alloc_return error, don't free the address at 0. If this is a managed dataspace, there could be valid attachments which then gets lost. Make decreasing alignment search working. Continue with lower alignment restrictions in case the optimal alignment wish can't be fulfilled.
This commit is contained in:
parent
30d004ab64
commit
e285ecb76c
@ -414,24 +414,19 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size,
|
||||
Range_allocator::Alloc_return alloc_return =
|
||||
_map.alloc_aligned(size, &attach_at, align_log2);
|
||||
|
||||
if (!alloc_return.ok())
|
||||
_map.free(attach_at);
|
||||
|
||||
typedef Range_allocator::Alloc_return Alloc_return;
|
||||
|
||||
switch (alloc_return.value) {
|
||||
case Alloc_return::OK: break; /* switch */
|
||||
case Alloc_return::OUT_OF_METADATA: throw Out_of_ram();
|
||||
case Alloc_return::RANGE_CONFLICT: throw Region_conflict();
|
||||
case Alloc_return::RANGE_CONFLICT: continue; /* for loop */
|
||||
}
|
||||
|
||||
break; /* for loop */
|
||||
|
||||
}
|
||||
|
||||
if (align_log2 < get_page_size_log2()) {
|
||||
_map.free(attach_at);
|
||||
if (align_log2 < get_page_size_log2())
|
||||
throw Region_conflict();
|
||||
}
|
||||
}
|
||||
|
||||
/* store attachment info in meta data */
|
||||
|
Loading…
x
Reference in New Issue
Block a user