[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH stable-0.15 32/36] Error check find_ram_offset
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH stable-0.15 32/36] Error check find_ram_offset |
Date: |
Wed, 28 Mar 2012 14:52:35 +0200 |
From: Alex Williamson <address@hidden>
Spotted via code review, we initialize offset to 0 to avoid a
compiler warning, but in the unlikely case that offset is
never set to something else, we should abort instead of return
a value that will almost certainly cause problems.
Signed-off-by: Alex Williamson <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>
(cherry picked from commit 3e837b2c05bc63fe2226baf3c29923d5a688593f)
Signed-off-by: Bruce Rogers <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
exec.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/exec.c b/exec.c
index 6fb589b..537a49f 100644
--- a/exec.c
+++ b/exec.c
@@ -2863,7 +2863,7 @@ static void *file_ram_alloc(RAMBlock *block,
static ram_addr_t find_ram_offset(ram_addr_t size)
{
RAMBlock *block, *next_block;
- ram_addr_t offset = 0, mingap = RAM_ADDR_MAX;
+ ram_addr_t offset = RAM_ADDR_MAX, mingap = RAM_ADDR_MAX;
if (QLIST_EMPTY(&ram_list.blocks))
return 0;
@@ -2879,10 +2879,17 @@ static ram_addr_t find_ram_offset(ram_addr_t size)
}
}
if (next - end >= size && next - end < mingap) {
- offset = end;
+ offset = end;
mingap = next - end;
}
}
+
+ if (offset == RAM_ADDR_MAX) {
+ fprintf(stderr, "Failed to find gap of requested size: %" PRIu64 "\n",
+ (uint64_t)size);
+ abort();
+ }
+
return offset;
}
--
1.7.7
- [Qemu-devel] [PATCH stable-0.15 27/36] block: reinitialize across bdrv_close()/bdrv_open(), (continued)
- [Qemu-devel] [PATCH stable-0.15 27/36] block: reinitialize across bdrv_close()/bdrv_open(), Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 21/36] Teach block/vdi about "discarded" (no longer allocated) blocks, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 17/36] vns/tls: don't use depricated gnutls functions, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 06/36] compatfd.c: Don't pass NULL pointer to SYS_signalfd, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 29/36] vmdk: Fix possible segfaults, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 22/36] vmdk: Improve error handling, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 28/36] qxl: stride fixup, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 19/36] hda: do not mix output and input streams, RHBZ #740493, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 26/36] qcow: Fix bdrv_write_compressed error handling, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 33/36] pc: add pc-0.15, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 32/36] Error check find_ram_offset,
Andreas Färber <=
- [Qemu-devel] [PATCH stable-0.15 31/36] cpu-common: Have a ram_addr_t of uint64 with Xen., Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 34/36] pc: fix event_idx compatibility for virtio devices, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 36/36] qemu_vmalloc: align properly for transparent hugepages and KVM, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 24/36] console: Fix rendering of VGA underline, Andreas Färber, 2012/03/28
- [Qemu-devel] [PATCH stable-0.15 30/36] pc: Fix floppy drives with if=none, Andreas Färber, 2012/03/28
- Re: [Qemu-devel] [PATCH stable-0.15 00/36] Preparing 0.15.2, Stefan Weil, 2012/03/28