[Spice-devel,18/19] qxl_surface: don't unlink surface 0

Submitted by Alon Levy on May 31, 2012, 10:24 a.m.

Details

Message ID 1338459893-1980-19-git-send-email-alevy@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Alon Levy May 31, 2012, 10:24 a.m.
The primary surface, i.e. qxl->primary, the only surface with id==0, is
allocated in qxl_surface_cache_create_primary with prev==next==NULL.
Unlinking it was producing a wrong cache->free_surfaces == NULL. This
was not a problem because unlinking the primary only happened in
switch_host, which then called surface_cache_init. In a following commit
switch_host is simplified to destroy-primary+create-primary, so this bug
needs to be fixed first to avoid leaking surfaces and reaching a no
surface available situation.
---
 src/qxl_surface.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index 669a022..f3a75fa 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -731,10 +731,12 @@  qxl_surface_set_pixmap (qxl_surface_t *surface, PixmapPtr pixmap)
 static void
 unlink_surface (qxl_surface_t *surface)
 {
-    if (surface->prev)
-	surface->prev->next = surface->next;
-    else
-	surface->cache->live_surfaces = surface->next;
+    if (surface->id != 0) {
+        if (surface->prev)
+            surface->prev->next = surface->next;
+        else
+            surface->cache->live_surfaces = surface->next;
+    }
 
     debug_surface_log(surface->cache);