aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2013-03-11 10:20:21 +0100
committerMichael S. Tsirkin <mst@redhat.com>2013-03-26 21:02:17 +0200
commit49cd9ac6a1929467e2df5783a5183fc7708ec3ff (patch)
treebf504638c2c65b71604f5c7b87ce090acd608c44
parent8c7f3dd05e4f1ee90000c89e428e69ae2e6bd691 (diff)
exec: assert that RAMBlock size is non-zero
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>
-rw-r--r--exec.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/exec.c b/exec.c
index 8a6aac36e3..786987a016 100644
--- 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;