sna: Nullify gpu_bo after free in case final release is deferred in destroy

As we may defer the actual release of the pixmap until after completion
of the last shm operation, we need to make sure in that case we mark the
GPU bo as released to prevent a use-after-free.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-09-01 12:15:47 +01:00
parent c4d9940141
commit b56e8c5105
1 changed files with 3 additions and 1 deletions

View File

@ -1073,8 +1073,10 @@ static Bool sna_destroy_pixmap(PixmapPtr pixmap)
sna = to_sna_from_pixmap(pixmap);
/* Always release the gpu bo back to the lower levels of caching */
if (priv->gpu_bo)
if (priv->gpu_bo) {
kgem_bo_destroy(&sna->kgem, priv->gpu_bo);
priv->gpu_bo = NULL;
}
if (priv->shm && kgem_bo_is_busy(priv->cpu_bo)) {
sna_add_flush_pixmap(sna, priv, priv->cpu_bo);