From 6c5fb84f4de346b06e5a538e683c5a118f2579bc Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 27 Jan 2012 14:08:57 +0000 Subject: [PATCH] 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 --- src/sna/sna_glyphs.c | 23 ++++++++++++++--------- 1 file 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;