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:
Alexander Boettcher 2018-05-30 00:20:16 +02:00 committed by Christian Helmuth
parent 30d004ab64
commit e285ecb76c
1 changed files with 3 additions and 8 deletions

View File

@ -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 */