aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2018-10-23 17:23:05 +0200
committerEduardo Habkost <ehabkost@redhat.com>2018-12-11 15:45:22 -0200
commit5e6aa26723f3eb67016282709fda7835a975f1ab (patch)
tree46e6c6f677b9758b2f297d3904fad7e61cc0be72
parent3e18dbbb13a476072b98ff3250d4558b446fa7b8 (diff)
downloadqemu-5e6aa26723f3eb67016282709fda7835a975f1ab.zip
qemu-5e6aa26723f3eb67016282709fda7835a975f1ab.tar.gz
qemu-5e6aa26723f3eb67016282709fda7835a975f1ab.tar.bz2
memory-device: avoid overflows on very huge devices
Should not be a problem right now, but it could theoretically happen in the future. Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181023152306.3123-7-david@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
-rw-r--r--hw/mem/memory-device.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 996ad14..8be63c8 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -85,7 +85,8 @@ static void memory_device_check_addable(MachineState *ms, uint64_t size,
/* will we exceed the total amount of memory specified */
memory_device_used_region_size(OBJECT(ms), &used_region_size);
- if (used_region_size + size > ms->maxram_size - ms->ram_size) {
+ if (used_region_size + size < used_region_size ||
+ used_region_size + size > ms->maxram_size - ms->ram_size) {
error_setg(errp, "not enough space, currently 0x%" PRIx64
" in use of total space for memory devices 0x" RAM_ADDR_FMT,
used_region_size, ms->maxram_size - ms->ram_size);