diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-09-30 08:49:34 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-09-30 09:04:25 +0100 |
commit | 2eab5ef751d7e9caabd7df171cdbb5e784059998 (patch) | |
tree | c7e297b5df9690f10598f8991bb65b33137b9faf | |
parent | 45b351412b8ba81f4fef2f64540d87cbf16359fd (diff) |
sna: Make sure the CPU bo is destroyed if we fail to mmap it during alloc
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_accel.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 7f64741a..7001eb87 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -435,15 +435,19 @@ sna_pixmap_alloc_cpu(struct sna *sna, pixmap->drawable.bitsPerPixel, from_gpu ? 0 : CREATE_CPU_MAP | CREATE_INACTIVE); if (priv->cpu_bo) { - DBG(("%s: allocated CPU handle=%d (snooped? %d)\n", __FUNCTION__, - priv->cpu_bo->handle, priv->cpu_bo->snoop)); - priv->ptr = kgem_bo_map__cpu(&sna->kgem, priv->cpu_bo); priv->stride = priv->cpu_bo->pitch; + if (priv->ptr) { + DBG(("%s: allocated CPU handle=%d (snooped? %d)\n", __FUNCTION__, + priv->cpu_bo->handle, priv->cpu_bo->snoop)); #ifdef DEBUG_MEMORY - sna->debug_memory.cpu_bo_allocs++; - sna->debug_memory.cpu_bo_bytes += kgem_bo_size(priv->cpu_bo); + sna->debug_memory.cpu_bo_allocs++; + sna->debug_memory.cpu_bo_bytes += kgem_bo_size(priv->cpu_bo); + } else { + kgem_bo_destroy(&sna->kgem, priv->cpu_bo); + priv->cpu_bo = NULL; #endif + } } } |