From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PATCH for-2.12] hw/char/serial: Fix crash when serial_mm_init() is used with -nodefaults
Date: Mon, 19 Mar 2018 16:00:16 +0100 [thread overview]
Message-ID: <1521471616-24157-1-git-send-email-thuth@redhat.com> (raw)
Quite a lot of boards call serial_mm_init() directly with a value from
the serial_hds[] table. However, this table is only containing NULL
if QEMU has been started with "-nodefaults":
$ gdb --args arm-softmmu/qemu-system-arm -S -nodefaults -M cubieboard
(gdb) r
Program received signal SIGSEGV, Segmentation fault.
qemu_chr_fe_init (b=b@entry=0x555556cc4260, s=s@entry=0x0, errp=0x55555697eb40 <error_abort>)
at chardev/char-fe.c:210
210 } else if (s->be) {
Since calling serial_mm_init with a NULL pointer seems to be a common
pattern between many boards, let's simply fix this by creating a "null"
chardev on the fly in this case.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/char/serial.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index eb72191..c1f7ff7 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -1040,6 +1040,10 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
{
SerialState *s;
+ if (!chr) {
+ chr = qemu_chardev_new(NULL, TYPE_CHARDEV_NULL, NULL, &error_abort);
+ }
+
s = g_malloc0(sizeof(SerialState));
s->it_shift = it_shift;
--
1.8.3.1
reply other threads:[~2018-03-19 15:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1521471616-24157-1-git-send-email-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@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 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).