From 1cc43dc97bd6438d7fc808cb5ee449889a966bdf Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 15 Dec 2011 00:00:56 +0000 Subject: [PATCH] sna: More missing move-to-cpu allocation checks Signed-off-by: Chris Wilson --- src/sna/sna_glyphs.c | 16 ++++++++++------ src/sna/sna_render.c | 8 +++++--- src/sna/sna_tiling.c | 15 ++++++++++----- src/sna/sna_trapezoids.c | 24 +++++++++++++++--------- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index c3864a12..e065c6a2 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -1023,13 +1023,17 @@ glyphs_fallback(CARD8 op, if (!RegionNotEmpty(®ion)) return; - sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion, true); - if (dst->alphaMap) - sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true); + if (!sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion, true)) + return; + if (dst->alphaMap && + !sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true)) + return; if (src->pDrawable) { - sna_drawable_move_to_cpu(src->pDrawable, false); - if (src->alphaMap) - sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false); + if (!sna_drawable_move_to_cpu(src->pDrawable, false)) + return; + if (src->alphaMap && + !sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false)) + return; } RegionTranslate(®ion, -dst->pDrawable->x, -dst->pDrawable->y); diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index e10f4847..19385af0 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -954,8 +954,9 @@ sna_render_picture_fixup(struct sna *sna, __FUNCTION__, channel->pict_format, pitch, picture->format)); } - if (picture->pDrawable) - sna_drawable_move_to_cpu(picture->pDrawable, false); + if (picture->pDrawable && + !sna_drawable_move_to_cpu(picture->pDrawable, false)) + return 0; channel->bo = kgem_create_buffer(&sna->kgem, pitch*h, KGEM_BUFFER_WRITE, @@ -1098,7 +1099,8 @@ sna_render_picture_convert(struct sna *sna, return 0; } - sna_pixmap_move_to_cpu(pixmap, false); + if (!sna_pixmap_move_to_cpu(pixmap, false)) + return 0; src = pixman_image_create_bits(picture->format, pixmap->drawable.width, diff --git a/src/sna/sna_tiling.c b/src/sna/sna_tiling.c index bab299eb..83dbd8cf 100644 --- a/src/sna/sna_tiling.c +++ b/src/sna/sna_tiling.c @@ -201,11 +201,16 @@ sna_tiling_composite_done(struct sna *sna, } else { DBG(("%s -- falback\n", __FUNCTION__)); - sna_drawable_move_to_cpu(tile->dst->pDrawable, true); - if (tile->src->pDrawable) - sna_drawable_move_to_cpu(tile->src->pDrawable, false); - if (tile->mask && tile->mask->pDrawable) - sna_drawable_move_to_cpu(tile->mask->pDrawable, false); + if (!sna_drawable_move_to_cpu(tile->dst->pDrawable, true)) + goto done; + + if (tile->src->pDrawable && + !sna_drawable_move_to_cpu(tile->src->pDrawable, false)) + goto done; + + if (tile->mask && tile->mask->pDrawable && + !sna_drawable_move_to_cpu(tile->mask->pDrawable, false)) + goto done; fbComposite(tile->op, tile->src, tile->mask, tile->dst, diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c index b8b7bb16..8899f388 100644 --- a/src/sna/sna_trapezoids.c +++ b/src/sna/sna_trapezoids.c @@ -3176,7 +3176,8 @@ trapezoid_span_inplace(CARD8 op, PicturePtr src, PicturePtr dst, } region.data = NULL; - sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion, true); + if (!sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion, true)) + return true; pixmap = get_drawable_pixmap(dst->pDrawable); get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y); @@ -3312,13 +3313,17 @@ trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst, region.extents.y2 = dst_y + extents.y2; region.data = NULL; - sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion, true); - if (dst->alphaMap) - sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true); + if (!sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion, true)) + goto done; + if (dst->alphaMap && + !sna_drawable_move_to_cpu(dst->alphaMap->pDrawable, true)) + goto done; if (src->pDrawable) { - sna_drawable_move_to_cpu(src->pDrawable, false); - if (src->alphaMap) - sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false); + if (!sna_drawable_move_to_cpu(src->pDrawable, false)) + goto done; + if (src->alphaMap && + !sna_drawable_move_to_cpu(src->alphaMap->pDrawable, false)) + goto done; } fbComposite(op, src, mask, dst, @@ -3327,6 +3332,7 @@ trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst, 0, 0, dst_x, dst_y, extents.x2, extents.y2); +done: FreePicture(mask, 0); } tor_fini(&tor); @@ -3881,8 +3887,8 @@ sna_add_traps(PicturePtr picture, INT16 x, INT16 y, int n, xTrap *t) } DBG(("%s -- fallback\n", __FUNCTION__)); - sna_drawable_move_to_cpu(picture->pDrawable, true); - fbAddTraps(picture, x, y, n, t); + if (sna_drawable_move_to_cpu(picture->pDrawable, true)) + fbAddTraps(picture, x, y, n, t); } static inline void