When there is no hint, the first un-overlapped range is the proper one. Just break the loop instead of iterate the whole list.
Signed-off-by: Wei Yang <richardw.y...@linux.intel.com> --- hw/mem/memory-device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index df3261b32a..413b514586 100644 --- a/hw/mem/memory-device.c +++ b/hw/mem/memory-device.c @@ -180,6 +180,8 @@ static uint64_t memory_device_get_free_addr(MachineState *ms, range_make_empty(&new); break; } + } else if (!hint) { + break; } } -- 2.17.1