From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 7/7] spice: fix initialization order
Date: Fri, 2 Nov 2012 10:35:19 +0100 [thread overview]
Message-ID: <1351848919-10388-8-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1351848919-10388-1-git-send-email-kraxel@redhat.com>
Register displaychangelistener last, after spice is fully initialized,
otherwise we may hit NULL pointer dereferences when qemu starts calling
our callbacks.
Commit e250d949feb1334828f27f0d145c35f29c4b7639 triggers this bug.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qxl.c | 10 ++++++++--
ui/spice-display.c | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/hw/qxl.c b/hw/qxl.c
index e7bf3a1..1bc2d32 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -2049,6 +2049,7 @@ static int qxl_init_primary(PCIDevice *dev)
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
VGACommonState *vga = &qxl->vga;
PortioList *qxl_vga_port_list = g_new(PortioList, 1);
+ int rc;
qxl->id = 0;
qxl_init_ramsize(qxl);
@@ -2063,9 +2064,14 @@ static int qxl_init_primary(PCIDevice *dev)
qemu_spice_display_init_common(&qxl->ssd, vga->ds);
qxl0 = qxl;
- register_displaychangelistener(vga->ds, &display_listener);
- return qxl_init_common(qxl);
+ rc = qxl_init_common(qxl);
+ if (rc != 0) {
+ return rc;
+ }
+
+ register_displaychangelistener(vga->ds, &display_listener);
+ return rc;
}
static int qxl_init_secondary(PCIDevice *dev)
diff --git a/ui/spice-display.c b/ui/spice-display.c
index fe2fdfb..0cc0116 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -573,7 +573,6 @@ void qemu_spice_display_init(DisplayState *ds)
{
assert(sdpy.ds == NULL);
qemu_spice_display_init_common(&sdpy, ds);
- register_displaychangelistener(ds, &display_listener);
sdpy.qxl.base.sif = &dpy_interface.base;
qemu_spice_add_interface(&sdpy.qxl.base);
@@ -581,4 +580,5 @@ void qemu_spice_display_init(DisplayState *ds)
qemu_spice_create_host_memslot(&sdpy);
qemu_spice_create_host_primary(&sdpy);
+ register_displaychangelistener(ds, &display_listener);
}
--
1.7.1
next prev parent reply other threads:[~2012-11-02 9:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-02 9:35 [Qemu-devel] [PULL 0/7] spice patch queue Gerd Hoffmann
2012-11-02 9:35 ` [Qemu-devel] [PATCH 1/7] hw/qxl: guest bug on primary create with stride %4 != 0 Gerd Hoffmann
2012-11-02 9:35 ` [Qemu-devel] [PATCH 2/7] hw/qxl: qxl_send_events: nop if stopped Gerd Hoffmann
2012-11-02 9:35 ` [Qemu-devel] [PATCH 3/7] qxl: fix cursor reset Gerd Hoffmann
2012-11-02 9:35 ` [Qemu-devel] [PATCH 4/7] qxl: call dpy_gfx_resize when entering vga mode Gerd Hoffmann
2012-11-02 9:35 ` [Qemu-devel] [PATCH 5/7] spice: switch to pixman Gerd Hoffmann
2012-11-02 9:35 ` [Qemu-devel] [PATCH 6/7] pflib: unused, remove it Gerd Hoffmann
2012-11-02 9:35 ` Gerd Hoffmann [this message]
2012-11-05 12:29 ` [Qemu-devel] [PULL 0/7] spice patch queue Gerd Hoffmann
2012-11-14 16:21 ` Anthony Liguori
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=1351848919-10388-8-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--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).