aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/fuzz/generic_fuzz.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qtest/fuzz/generic_fuzz.c')
-rw-r--r--tests/qtest/fuzz/generic_fuzz.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
index 6c67522717..0ea47298b7 100644
--- a/tests/qtest/fuzz/generic_fuzz.c
+++ b/tests/qtest/fuzz/generic_fuzz.c
@@ -240,10 +240,17 @@ void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr)
addr, &addr1, &l, true,
MEMTXATTRS_UNSPECIFIED);
- if (!(memory_region_is_ram(mr1) ||
- memory_region_is_romd(mr1)) && mr1 != sparse_mem_mr) {
+ /*
+ * If mr1 isn't RAM, address_space_translate doesn't update l. Use
+ * memory_access_size to identify the number of bytes that it is safe
+ * to write without accidentally writing to another MemoryRegion.
+ */
+ if (!memory_region_is_ram(mr1)) {
l = memory_access_size(mr1, l, addr1);
- } else {
+ }
+ if (memory_region_is_ram(mr1) ||
+ memory_region_is_romd(mr1) ||
+ mr1 == sparse_mem_mr) {
/* ROM/RAM case */
if (qtest_log_enabled) {
/*