From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cg5ru-0006XN-KN for qemu-devel@nongnu.org; Tue, 21 Feb 2017 03:32:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cg5rr-00049p-DN for qemu-devel@nongnu.org; Tue, 21 Feb 2017 03:32:18 -0500 Received: from mx5-phx2.redhat.com ([209.132.183.37]:40969) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cg5rr-00048d-50 for qemu-devel@nongnu.org; Tue, 21 Feb 2017 03:32:15 -0500 Date: Tue, 21 Feb 2017 03:32:04 -0500 (EST) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <910332417.8403823.1487665924940.JavaMail.zimbra@redhat.com> In-Reply-To: <1487665107-88004-1-git-send-email-liqiang6-s@360.cn> References: <1487665107-88004-1-git-send-email-liqiang6-s@360.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] spice-char: fix segfault in char_spice_finalize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Li Qiang Cc: pbonzini@redhat.com, marcandre lureau , qemu-devel@nongnu.org, Li Qiang Hi ----- Original Message ----- > 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. >=20 > Signed-off-by: Li Qiang Reviewed-by: Marc-Andr=C3=A9 Lureau > --- > spice-qemu-char.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > 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 =3D SPICE_CHARDEV(obj); > =20 > vmc_unregister_interface(s); > - QLIST_REMOVE(s, next); > + > + if (s->next.le_prev) { > + QLIST_REMOVE(s, next); > + } > =20 > g_free((char *)s->sin.subtype); > #if SPICE_SERVER_VERSION >=3D 0x000c02 > -- > 1.8.3.1 >=20 >=20