summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-10-16 14:09:08 +0100
committerJulien Cristau <jcristau@debian.org>2014-11-01 21:17:41 +0100
commita4d9637504ea4c97ca22d86c9f2e275f5253470d (patch)
treea48054a2fd0284423506894a57a7b67863345e4e
parenta7c207cc8e713092c51401baddbb3a30de398a34 (diff)
Xext/shm: Detach SHM segment after Pixmap is released
The GPU may still have a reference to the SHM segment which would only be finally released when the Pixmap is destroy. So we can only detach the SHM segment (and thereby making the memory unaccessible) after the backend has had a chance to flush any remaining references. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85058 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reported-and-tested-by: gedgon@gmail.com Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com> (cherry picked from commit 9b29fa957a397664463c7c78fbcc2f34d1993271) Signed-off-by: Julien Cristau <jcristau@debian.org>
-rw-r--r--Xext/shm.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/Xext/shm.c b/Xext/shm.c
index 4dad8b6c6..b78791836 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -248,21 +248,20 @@ ShmDestroyPixmap(PixmapPtr pPixmap)
{
ScreenPtr pScreen = pPixmap->drawable.pScreen;
ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
+ void *shmdesc = NULL;
Bool ret;
- if (pPixmap->refcnt == 1) {
- ShmDescPtr shmdesc;
-
- shmdesc = (ShmDescPtr) dixLookupPrivate(&pPixmap->devPrivates,
- shmPixmapPrivateKey);
- if (shmdesc)
- ShmDetachSegment((void *) shmdesc, pPixmap->drawable.id);
- }
+ if (pPixmap->refcnt == 1)
+ shmdesc = dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey);
pScreen->DestroyPixmap = screen_priv->destroyPixmap;
ret = (*pScreen->DestroyPixmap) (pPixmap);
screen_priv->destroyPixmap = pScreen->DestroyPixmap;
pScreen->DestroyPixmap = ShmDestroyPixmap;
+
+ if (shmdesc)
+ ShmDetachSegment(shmdesc, pPixmap->drawable.id);
+
return ret;
}