core: avoid freeing memory of unknown state

This should actually never happen. However if it happens, be a bit robuster
and don't provide the memory for re-use (which causes tons of other trouble
afterwards).

Issue #2505
This commit is contained in:
Alexander Boettcher 2017-08-24 13:23:02 +02:00 committed by Christian Helmuth
parent 404a82d5ee
commit cf2886dc8f

View File

@ -77,7 +77,13 @@ void Mapped_mem_allocator::free(void *addr, size_t size)
Block *b = static_cast<Block *>(_virt_alloc->_find_by_address((addr_t)addr));
if (!b) return;
_unmap_local((addr_t)addr, (addr_t)b->map_addr, b->size());
if (!_unmap_local((addr_t)addr, (addr_t)b->map_addr, b->size())) {
Genode::error("error on unmap virt=", addr, " phys=",
Hex_range<addr_t>((addr_t)b->map_addr, b->size()));
/* leak physical and virtual region because of unknown usage state */
return;
}
_phys_alloc->free(b->map_addr, b->size());
_virt_alloc->free(addr, b->size());
}