diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2016-07-04 13:06:35 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-07-04 13:06:35 +0100 |
commit | 39e0b03dec518254fabd2acff29548d3f1d2b754 (patch) | |
tree | 2f7ed6995935901c71b451261c67d89637ec20ff | |
parent | a7aeb5f7b2c713e2ab7e0a142e0c89f7b2aa5bb7 (diff) | |
download | qemu-39e0b03dec518254fabd2acff29548d3f1d2b754.zip qemu-39e0b03dec518254fabd2acff29548d3f1d2b754.tar.gz qemu-39e0b03dec518254fabd2acff29548d3f1d2b754.tar.bz2 |
memory: Assert that memory_region_init_rom_device() ops aren't NULL
It doesn't make sense to pass a NULL ops argument to
memory_region_init_rom_device(), because the effect will
be that if the guest tries to write to the memory region
then QEMU will segfault. Catch the bug earlier by sanity
checking the arguments to this function, and remove the
misleading documentation that suggests that passing NULL
might be sensible.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1467122287-24974-4-git-send-email-peter.maydell@linaro.org
-rw-r--r-- | include/exec/memory.h | 5 | ||||
-rw-r--r-- | memory.c | 1 |
2 files changed, 2 insertions, 4 deletions
diff --git a/include/exec/memory.h b/include/exec/memory.h index 2d9ea3c..3e4d416 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -467,12 +467,9 @@ void memory_region_init_rom(MemoryRegion *mr, * memory_region_init_rom_device: Initialize a ROM memory region. Writes are * handled via callbacks. * - * If NULL callbacks pointer is given, then I/O space is not supposed to be - * handled by QEMU itself. Any access via the memory API will cause an abort(). - * * @mr: the #MemoryRegion to be initialized. * @owner: the object that tracks the region's reference count - * @ops: callbacks for write access handling. + * @ops: callbacks for write access handling (must not be NULL). * @name: the name of the region. * @size: size of the region. * @errp: pointer to Error*, to store an error if it happens. @@ -1399,6 +1399,7 @@ void memory_region_init_rom_device(MemoryRegion *mr, uint64_t size, Error **errp) { + assert(ops); memory_region_init(mr, owner, name, size); mr->ops = ops; mr->opaque = opaque; |