From 52f39ae1697bef86471b7c5eef8553661f255b67 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 21 Mar 2012 13:31:03 +0000 Subject: [PATCH] sna: Assert that the bo created is large enough Double check that the maximum access size computed from the bo parameters is within the allocated size for the bo. Signed-off-by: Chris Wilson --- src/sna/kgem.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index c0229005..26abdd07 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -2509,6 +2509,7 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem, bo->delta = 0; DBG((" 1:from active: pitch=%d, tiling=%d, handle=%d, id=%d\n", bo->pitch, bo->tiling, bo->handle, bo->unique_id)); + assert(bo->pitch*kgem_aligned_height(kgem, height, bo->tiling) <= kgem_bo_size(bo)); bo->refcnt = 1; return bo; } @@ -2561,6 +2562,7 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem, bo->pitch, bo->tiling, bo->handle, bo->unique_id)); assert(bo->reusable); assert(bo->domain != DOMAIN_GPU && !kgem_busy(kgem, bo->handle)); + assert(bo->pitch*kgem_aligned_height(kgem, height, bo->tiling) <= kgem_bo_size(bo)); bo->refcnt = 1; return bo; } @@ -2615,6 +2617,7 @@ search_again: bo->delta = 0; DBG((" 1:from active: pitch=%d, tiling=%d, handle=%d, id=%d\n", bo->pitch, bo->tiling, bo->handle, bo->unique_id)); + assert(bo->pitch*kgem_aligned_height(kgem, height, bo->tiling) <= kgem_bo_size(bo)); bo->refcnt = 1; return bo; } @@ -2636,6 +2639,7 @@ search_again: bo->delta = 0; DBG((" 1:from active: pitch=%d, tiling=%d, handle=%d, id=%d\n", bo->pitch, bo->tiling, bo->handle, bo->unique_id)); + assert(bo->pitch*kgem_aligned_height(kgem, height, bo->tiling) <= kgem_bo_size(bo)); bo->refcnt = 1; return bo; } @@ -2669,6 +2673,7 @@ search_again: bo->delta = 0; DBG((" 1:from active: pitch=%d, tiling=%d, handle=%d, id=%d\n", bo->pitch, bo->tiling, bo->handle, bo->unique_id)); + assert(bo->pitch*kgem_aligned_height(kgem, height, bo->tiling) <= kgem_bo_size(bo)); bo->refcnt = 1; return bo; } @@ -2715,6 +2720,7 @@ search_again: bo->delta = 0; DBG((" 1:from active: pitch=%d, tiling=%d, handle=%d, id=%d\n", bo->pitch, bo->tiling, bo->handle, bo->unique_id)); + assert(bo->pitch*kgem_aligned_height(kgem, height, bo->tiling) <= kgem_bo_size(bo)); bo->refcnt = 1; return bo; } @@ -2773,6 +2779,7 @@ search_inactive: assert((flags & CREATE_INACTIVE) == 0 || bo->domain != DOMAIN_GPU); assert((flags & CREATE_INACTIVE) == 0 || !kgem_busy(kgem, bo->handle)); + assert(bo->pitch*kgem_aligned_height(kgem, height, bo->tiling) <= kgem_bo_size(bo)); bo->refcnt = 1; return bo; }