* [Qemu-devel] [PATCH] spice-char: fix segfault in char_spice_finalize
@ 2017-02-21 3:37 Li Qiang
2017-02-21 7:43 ` Marc-André Lureau
0 siblings, 1 reply; 2+ messages in thread
From: Li Qiang @ 2017-02-21 3:37 UTC (permalink / raw)
To: pbonzini, marcandre.lureau, qemu-devel; +Cc: Li Qiang
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>
---
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..15dbf9c 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 (spice_chars.lh_first) {
+ QLIST_REMOVE(s, next);
+ }
g_free((char *)s->sin.subtype);
#if SPICE_SERVER_VERSION >= 0x000c02
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] spice-char: fix segfault in char_spice_finalize
2017-02-21 3:37 [Qemu-devel] [PATCH] spice-char: fix segfault in char_spice_finalize Li Qiang
@ 2017-02-21 7:43 ` Marc-André Lureau
0 siblings, 0 replies; 2+ messages in thread
From: Marc-André Lureau @ 2017-02-21 7:43 UTC (permalink / raw)
To: Li Qiang, pbonzini, qemu-devel; +Cc: Li Qiang
Hi
On Tue, Feb 21, 2017 at 7:38 AM Li Qiang <liq3ea@gmail.com> wrote:
> 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>
> ---
> 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..15dbf9c 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 (spice_chars.lh_first) {
> + QLIST_REMOVE(s, next);
> + }
>
>
The condition you added is unrelated. It should rather be "if
(s->next.le_prev)". (there is a similar test in block.c)
g_free((char *)s->sin.subtype);
> #if SPICE_SERVER_VERSION >= 0x000c02
> --
> 1.8.3.1
>
>
> --
Marc-André Lureau
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-21 7:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21 3:37 [Qemu-devel] [PATCH] spice-char: fix segfault in char_spice_finalize Li Qiang
2017-02-21 7:43 ` Marc-André Lureau
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.