Patchwork vnc_refresh: return if vd->timer is NULL

login
register
mail settings
Submitter Stefano Stabellini
Date Jan. 11, 2010, 5:30 p.m.
Message ID <alpine.DEB.2.00.1001111725500.14945@kaball-desktop>
Download mbox | patch
Permalink /patch/42647/
State New
Headers show

Comments

Stefano Stabellini - Jan. 11, 2010, 5:30 p.m.
Hi all,
calling vnc_update_client in vnc_refresh might have the unlikely side
effect of setting vd->timer = NULL, if the last vnc client disconnected.
In this case we have to return from vnc_refresh without updating the
timer, otherwise we cause a segfault.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

---
Anthony Liguori - Jan. 12, 2010, 7:35 p.m.
On 01/11/2010 11:30 AM, Stefano Stabellini wrote:
> Hi all,
> calling vnc_update_client in vnc_refresh might have the unlikely side
> effect of setting vd->timer = NULL, if the last vnc client disconnected.
> In this case we have to return from vnc_refresh without updating the
> timer, otherwise we cause a segfault.
>
> Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>
> diff --git a/vnc.c b/vnc.c
> index c54c6e0..58eac73 100644
> --- a/vnc.c
> +++ b/vnc.c
> @@ -2305,6 +2305,10 @@ static void vnc_refresh(void *opaque)
>           rects += vnc_update_client(vs, has_dirty);
>           vs = vs->next;
>       }
> +    /* vd->timer could be NULL now if the last client disconnected,
> +     * in this case don't update the timer */
> +    if (vd->timer == NULL)
> +        return;
>
>       if (has_dirty&&  rects) {
>           vd->timer_interval /= 2;
>
>
>
>

Patch

diff --git a/vnc.c b/vnc.c
index c54c6e0..58eac73 100644
--- a/vnc.c
+++ b/vnc.c
@@ -2305,6 +2305,10 @@  static void vnc_refresh(void *opaque)
         rects += vnc_update_client(vs, has_dirty);
         vs = vs->next;
     }
+    /* vd->timer could be NULL now if the last client disconnected,
+     * in this case don't update the timer */
+    if (vd->timer == NULL)
+        return;
 
     if (has_dirty && rects) {
         vd->timer_interval /= 2;