base-nova: fix map for small sizes

Changes to the platform driver triggered a map() error while mapping an
address block at 0x3000 of size 0x800. Since the mapped size was larger, the
loop continued and tried mapping address 0x4000 where no dataspace was
found.

genodelabs/genode#4761
This commit is contained in:
Johannes Schlatow 2023-05-05 09:21:01 +02:00 committed by Christian Helmuth
parent cb0546aa9b
commit d3d3351b99

View File

@ -99,7 +99,7 @@ void Pd_session_component::map(addr_t virt, addr_t size)
while (size) {
addr_t mapped = _address_space.apply_to_dataspace(virt, lambda);
virt += mapped;
size = size < mapped ? size : size - mapped;
size = size < mapped ? 0 : size - mapped;
}
} catch (...) {
error(__func__, " failed ", Hex(virt), "+", Hex(size));