qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] memory region: check the old.mmio.read status
@ 2018-09-12 12:32 Li Qiang
  2018-09-12 12:54 ` Peter Maydell
  0 siblings, 1 reply; 9+ messages in thread
From: Li Qiang @ 2018-09-12 12:32 UTC (permalink / raw)
  To: mst, ehabkost, marcandre.lureau, lersek, peter.maydell, pbonzini,
	ppandit
  Cc: qemu-devel, Li Qiang

To avoid NULL-deref for the devices without read callbacks

Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 memory.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/memory.c b/memory.c
index 9b73892768..48d025426b 100644
--- a/memory.c
+++ b/memory.c
@@ -406,6 +406,10 @@ static MemTxResult memory_region_oldmmio_read_accessor(MemoryRegion *mr,
 {
     uint64_t tmp;
 
+    if (!mr->ops->old_mmio.read[ctz32(size)]) {
+        return MEMTX_DECODE_ERROR;
+    }
+
     tmp = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);
     if (mr->subpage) {
         trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, size);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-09-13  4:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-12 12:32 [Qemu-devel] [PATCH] memory region: check the old.mmio.read status Li Qiang
2018-09-12 12:54 ` Peter Maydell
2018-09-12 14:28   ` Li Qiang
2018-09-12 17:45     ` Laszlo Ersek
2018-09-12 17:43   ` Laszlo Ersek
2018-09-13  0:31     ` Peter Maydell
2018-09-13  1:36       ` Li Qiang
2018-09-13  4:31       ` Mark Cave-Ayland
2018-09-13  4:45         ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).