From: Thomas Huth Date: Mon, 28 Jul 2025 17:25:45 +0000 (+0200) Subject: system/physmem: Silence warning from ubsan X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2dbaf58bbe78f415ec867dc238f90321ed8a3f62;p=thirdparty%2Fqemu.git system/physmem: Silence warning from ubsan When compiling QEMU with --enable-ubsan there is a undefined behavior warning when running the bios-tables-test for example: .../system/physmem.c:3243:13: runtime error: applying non-zero offset 262144 to null pointer #0 0x55ac1df5fbc4 in address_space_write_rom_internal .../system/physmem.c:3243:13 The problem is that buf is indeed NULL if the function is e.g. called with type == FLUSH_CACHE. Add a check to fix the issue. Reviewed-by: David Hildenbrand Signed-off-by: Thomas Huth Message-ID: <20250728172545.314178-1-thuth@redhat.com> --- diff --git a/system/physmem.c b/system/physmem.c index f498572fc82..311011156c7 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3231,8 +3231,10 @@ static inline MemTxResult address_space_write_rom_internal(AddressSpace *as, } } len -= l; - buf += l; addr += l; + if (buf) { + buf += l; + } } return MEMTX_OK; }