[PATCH 18/19] qxl_surface: don't unlink surface 0

Alon Levy alevy at redhat.com
Thu May 31 03:24:52 PDT 2012


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(-)

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);
     
-- 
1.7.10.1



More information about the xorg-devel mailing list