qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Li Qiang <liq3ea@gmail.com>, Li Qiang <liqiang6-s@360.cn>
Subject: [Qemu-devel] [PATCH 18/21] spice-char: fix segfault in char_spice_finalize
Date: Fri,  3 Mar 2017 17:30:27 +0100	[thread overview]
Message-ID: <1488558630-21522-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1488558630-21522-1-git-send-email-pbonzini@redhat.com>

From: Li Qiang <liq3ea@gmail.com>

In 'qemu_chr_open_spice_vmc' if the 'psubtype' is NULL, it will
call 'char_spice_finalize'. But as the SpiceChardev is not inserted
in the 'spice_chars' list, the 'QLIST_REMOVE' will cause a segfault.
Add a detect to avoid it.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Message-Id: <1487665107-88004-1-git-send-email-liqiang6-s@360.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 spice-qemu-char.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 6f46f46..4d1c76e 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -215,7 +215,10 @@ static void char_spice_finalize(Object *obj)
     SpiceChardev *s = SPICE_CHARDEV(obj);
 
     vmc_unregister_interface(s);
-    QLIST_REMOVE(s, next);
+
+    if (s->next.le_prev) {
+        QLIST_REMOVE(s, next);
+    }
 
     g_free((char *)s->sin.subtype);
 #if SPICE_SERVER_VERSION >= 0x000c02
-- 
1.8.3.1

  reply	other threads:[~2017-03-03 16:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 16:30 [Qemu-devel] [PULL v5 00/21] Misc patches for QEMU soft freeze Paolo Bonzini
2017-03-03 16:30 ` Paolo Bonzini [this message]
2017-03-03 16:30 ` [Qemu-devel] [PATCH 19/21] x86: Work around SMI migration breakages Paolo Bonzini
2017-03-03 16:30 ` [Qemu-devel] [PATCH 20/21] memory: show region offset and ROM/RAM type in "info mtree -f" Paolo Bonzini
2017-03-03 16:30 ` [Qemu-devel] [PATCH 21/21] iscsi: fix missing unlock Paolo Bonzini
2017-03-04 12:50 ` [Qemu-devel] [PULL v5 00/21] Misc patches for QEMU soft freeze Peter Maydell

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=1488558630-21522-2-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=liq3ea@gmail.com \
    --cc=liqiang6-s@360.cn \
    --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).