qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 08/16] memory: Disallow resizing to 0


From: David Hildenbrand
Subject: [PATCH v2 08/16] memory: Disallow resizing to 0
Date: Wed, 12 Feb 2020 14:35:53 +0100

Memory regions / qemu ramblocks always have to have a size > 0.
Especially, otherwise, ramblock_ptr() will bail out with an assert.
Enforce this.

Signed-off-by: David Hildenbrand <address@hidden>
---
 exec.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/exec.c b/exec.c
index 5bc9b231c4..161e40e16e 100644
--- a/exec.c
+++ b/exec.c
@@ -2160,6 +2160,11 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, 
Error **errp)
         return 0;
     }
 
+    if (!newsize) {
+        error_setg_errno(errp, EINVAL, "Length cannot be 0: %s", block->idstr);
+        return -EINVAL;
+    }
+
     if (!qemu_ram_is_resizable(block)) {
         error_setg_errno(errp, EINVAL,
                          "Length mismatch: %s: 0x" RAM_ADDR_FMT
-- 
2.24.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]