From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Peter Xu <peterx@redhat.com>,
David Hildenbrand <david@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH] system/physmem: Silence warning from ubsan
Date: Mon, 28 Jul 2025 19:25:45 +0200 [thread overview]
Message-ID: <20250728172545.314178-1-thuth@redhat.com> (raw)
From: Thomas Huth <thuth@redhat.com>
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.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
system/physmem.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/system/physmem.c b/system/physmem.c
index 130c148ffb5..00333ffa7f7 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3240,8 +3240,10 @@ static inline MemTxResult address_space_write_rom_internal(AddressSpace *as,
}
}
len -= l;
- buf += l;
addr += l;
+ if (buf) {
+ buf += l;
+ }
}
return MEMTX_OK;
}
--
2.50.1
next reply other threads:[~2025-07-28 17:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-28 17:25 Thomas Huth [this message]
2025-07-28 18:43 ` [PATCH] system/physmem: Silence warning from ubsan Philippe Mathieu-Daudé
2025-07-29 19:21 ` Peter Xu
2025-07-28 18:44 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250728172545.314178-1-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=david@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.