]> git.proxmox.com Git - qemu.git/commitdiff
exec: assert that RAMBlock size is non-zero
authorStefan Hajnoczi <stefanha@redhat.com>
Mon, 11 Mar 2013 09:20:21 +0000 (10:20 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 26 Mar 2013 19:02:17 +0000 (21:02 +0200)
find_ram_offset() does not handle size=0 gracefully.  It hands out the
same RAMBlock offset multiple times, leading to obscure failures later
on.

Add an assert to warn early if something is incorrectly allocating a
zero size RAMBlock.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
exec.c

diff --git a/exec.c b/exec.c
index 8a6aac36e347399ffa448fac4cab1fae2c135110..786987a0165dd6acc01a6677957d7019e648d5a7 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -925,6 +925,8 @@ static ram_addr_t find_ram_offset(ram_addr_t size)
     RAMBlock *block, *next_block;
     ram_addr_t offset = RAM_ADDR_MAX, mingap = RAM_ADDR_MAX;
 
+    assert(size != 0); /* it would hand out same offset multiple times */
+
     if (QTAILQ_EMPTY(&ram_list.blocks))
         return 0;