From efc6cc2b83aebb56a78a7aa82178ec9bc461e885 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sun, 25 Feb 2018 00:29:47 -0500 Subject: [PATCH] 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. Backports commit 39e0b03dec518254fabd2acff29548d3f1d2b754 from qemu --- qemu/include/exec/memory.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/qemu/include/exec/memory.h b/qemu/include/exec/memory.h index d9cdd06f..cfbb8b21 100644 --- a/qemu/include/exec/memory.h +++ b/qemu/include/exec/memory.h @@ -416,12 +416,9 @@ void memory_region_init_rom(struct uc_struct *uc, * 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.