Patchwork vnc: check fd before calling qemu_set_fd_handler2() in vnc_client_write()

login
register
mail settings
Submitter Yoshiaki Tamura
Date Aug. 20, 2010, 10:10 a.m.
Message ID <1282299041-18786-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp>
Download mbox | patch
Permalink /patch/62263/
State New
Headers show

Comments

Yoshiaki Tamura - Aug. 20, 2010, 10:10 a.m.
Setting fd = -1 to qemu_set_fd_handler2() causes bus error at FD_SET
in main_loop_wait().

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
---
 ui/vnc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Corentin Chary - Aug. 20, 2010, 2:17 p.m.
On Fri, Aug 20, 2010 at 12:10 PM, Yoshiaki Tamura
<tamura.yoshiaki@lab.ntt.co.jp> wrote:
> Setting fd = -1 to qemu_set_fd_handler2() causes bus error at FD_SET
> in main_loop_wait().
>
> Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
> ---
>  ui/vnc.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/ui/vnc.c b/ui/vnc.c
> index 7fc40ac..c7a1831 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -1184,7 +1184,7 @@ void vnc_client_write(void *opaque)
>     vnc_lock_output(vs);
>     if (vs->output.offset) {
>         vnc_client_write_locked(opaque);
> -    } else {
> +    } else if (vs->csock != -1) {
>         qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);
>     }
>     vnc_unlock_output(vs);
> --
> 1.7.1.1
>
>

Acked-By: Corentin Chary <corentincj@iksaif.net>

Patch

diff --git a/ui/vnc.c b/ui/vnc.c
index 7fc40ac..c7a1831 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1184,7 +1184,7 @@  void vnc_client_write(void *opaque)
     vnc_lock_output(vs);
     if (vs->output.offset) {
         vnc_client_write_locked(opaque);
-    } else {
+    } else if (vs->csock != -1) {
         qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);
     }
     vnc_unlock_output(vs);