[PATCH 20/27] glamor: Add missing prepares on the GC during fb fallbacks.

Eric Anholt eric at anholt.net
Tue Mar 11 14:30:34 PDT 2014


We had regressions in CopyPlane reported by xts5, because we were
(successfully!) dereferencing the null pixmap->devPrivate.ptr for a
tile or stipple without having done a prepare.

Signed-off-by: Eric Anholt <eric at anholt.net>
---
 glamor/glamor_copyarea.c  | 4 +++-
 glamor/glamor_copyplane.c | 4 +++-
 glamor/glamor_putimage.c  | 4 +++-
 glamor/glamor_setspans.c  | 4 +++-
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
index b367e03..dac1559 100644
--- a/glamor/glamor_copyarea.c
+++ b/glamor/glamor_copyarea.c
@@ -571,10 +571,12 @@ _glamor_copy_n_to_n(DrawablePtr src,
                     glamor_get_drawable_location(dst));
 
     if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW) &&
-        glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
+        glamor_prepare_access(src, GLAMOR_ACCESS_RO) &&
+        glamor_prepare_access_gc(gc)) {
         fbCopyNtoN(src, dst, gc, box, nbox,
                    dx, dy, reverse, upsidedown, bitplane, closure);
     }
+    glamor_finish_access_gc(gc);
     glamor_finish_access(src);
     glamor_finish_access(dst);
     ok = TRUE;
diff --git a/glamor/glamor_copyplane.c b/glamor/glamor_copyplane.c
index 50e9cf3..2bd2de3 100644
--- a/glamor/glamor_copyplane.c
+++ b/glamor/glamor_copyplane.c
@@ -39,10 +39,12 @@ _glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
         goto fail;
 
     if (glamor_prepare_access(pDst, GLAMOR_ACCESS_RW) &&
-        glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO)) {
+        glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO) &&
+        glamor_prepare_access_gc(pGC)) {
         *pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
                                dstx, dsty, bitPlane);
     }
+    glamor_finish_access_gc(pGC);
     glamor_finish_access(pSrc);
     glamor_finish_access(pDst);
     return TRUE;
diff --git a/glamor/glamor_putimage.c b/glamor/glamor_putimage.c
index a4f97cd..b77238c 100644
--- a/glamor/glamor_putimage.c
+++ b/glamor/glamor_putimage.c
@@ -227,9 +227,11 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
     glamor_fallback(": to %p (%c)\n",
                     drawable, glamor_get_drawable_location(drawable));
  fail:
-    if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
+    if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) &&
+        glamor_prepare_access_gc(gc)) {
         fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap, bits);
     }
+    glamor_finish_access_gc(gc);
     glamor_finish_access(drawable);
 }
 #endif
diff --git a/glamor/glamor_setspans.c b/glamor/glamor_setspans.c
index 664f8ac..ced302a 100644
--- a/glamor/glamor_setspans.c
+++ b/glamor/glamor_setspans.c
@@ -86,9 +86,11 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
 
     glamor_fallback("to %p (%c)\n",
                     drawable, glamor_get_drawable_location(drawable));
-    if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
+    if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
+        glamor_prepare_access_gc(gc)) {
         fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
     }
+    glamor_finish_access_gc(gc);
     glamor_finish_access(drawable);
     ret = TRUE;
 
-- 
1.9.0



More information about the xorg-devel mailing list