summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-27 14:08:57 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-27 14:11:50 +0000
commit6c5fb84f4de346b06e5a538e683c5a118f2579bc (patch)
tree3f8529b6e44e3b2a8ea82b6967f0e6530bb3e7da
parent86f1ae9164a94323c08e1dc6cb301e5bc1126b10 (diff)
sna/glyphs: Check that we attached to the cache pixmaps upon creation
If the hw is wedged, then the pixmap creation routines will return an ordinary unattached pixmap. The code presumed that it would only return a pixmap with an attached bo, and so would segfault as it chased the invalid pointer after a GPU hang and the server was restarted. Considering that we already checked that the GPU wasn't wedged before we started, this is just mild paranoia, but on a run-once piece of code. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_glyphs.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index ee407076..bef17749 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -157,12 +157,15 @@ static Bool realize_glyph_caches(struct sna *sna)
for (i = 0; i < ARRAY_SIZE(formats); i++) {
struct sna_glyph_cache *cache = &sna->render.glyph[i];
+ struct sna_pixmap *priv;
PixmapPtr pixmap;
- PicturePtr picture;
+ PicturePtr picture = NULL;
+ PictFormatPtr pPictFormat;
CARD32 component_alpha;
int depth = PIXMAN_FORMAT_DEPTH(formats[i]);
int error;
- PictFormatPtr pPictFormat = PictureMatchFormat(screen, depth, formats[i]);
+
+ pPictFormat = PictureMatchFormat(screen, depth, formats[i]);
if (!pPictFormat)
goto bail;
@@ -175,16 +178,18 @@ static Bool realize_glyph_caches(struct sna *sna)
if (!pixmap)
goto bail;
- /* Prevent the cache from ever being paged out */
- sna_pixmap(pixmap)->pinned = true;
+ priv = sna_pixmap(pixmap);
+ if (priv != NULL) {
+ /* Prevent the cache from ever being paged out */
+ priv->pinned = true;
- component_alpha = NeedsComponent(pPictFormat->format);
- picture = CreatePicture(0, &pixmap->drawable, pPictFormat,
- CPComponentAlpha, &component_alpha,
- serverClient, &error);
+ component_alpha = NeedsComponent(pPictFormat->format);
+ picture = CreatePicture(0, &pixmap->drawable, pPictFormat,
+ CPComponentAlpha, &component_alpha,
+ serverClient, &error);
+ }
screen->DestroyPixmap(pixmap);
-
if (!picture)
goto bail;