diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2016-06-14 19:00:18 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2016-06-16 15:20:13 +0900 |
commit | 5b4a8a7a6ed70a50be252fa9b34d3b3a17cdf91a (patch) | |
tree | eca537611d6ecfa3b8f8bd50b5bdc592201d52a2 /src/amdgpu_bo_helper.c | |
parent | c315c00e44afc91a7c8e2eab5af836d9643ebb88 (diff) |
Use amdgpu_set_pixmap_bo in amdgpu_set_shared_pixmap_backing
Fixes leaking any existing pixmap private.
While we're at it, also fix leaking the GBM BO if
amdgpu_glamor_create_textured_pixmap fails.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src/amdgpu_bo_helper.c')
-rw-r--r-- | src/amdgpu_bo_helper.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c index 5482ff0..7acd005 100644 --- a/src/amdgpu_bo_helper.c +++ b/src/amdgpu_bo_helper.c @@ -387,7 +387,7 @@ Bool amdgpu_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle) Bool ret; if (info->gbm) { - struct amdgpu_pixmap *priv; + struct amdgpu_buffer *bo; struct gbm_import_fd_data data; uint32_t bo_use = GBM_BO_USE_RENDERING; @@ -396,16 +396,10 @@ Bool amdgpu_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle) if (data.format == ~0U) return FALSE; - priv = calloc(1, sizeof(struct amdgpu_pixmap)); - if (!priv) + bo = calloc(1, sizeof(struct amdgpu_buffer)); + if (!bo) return FALSE; - - priv->bo = calloc(1, sizeof(struct amdgpu_buffer)); - if (!priv->bo) { - free(priv); - return FALSE; - } - priv->bo->ref_count = 1; + bo->ref_count = 1; data.fd = ihandle; data.width = ppix->drawable.width; @@ -415,27 +409,27 @@ Bool amdgpu_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle) if (ppix->drawable.bitsPerPixel == pScrn->bitsPerPixel) bo_use |= GBM_BO_USE_SCANOUT; - priv->bo->bo.gbm = gbm_bo_import(info->gbm, GBM_BO_IMPORT_FD, - &data, bo_use); - if (!priv->bo->bo.gbm) { - free(priv->bo); - free(priv); + bo->bo.gbm = gbm_bo_import(info->gbm, GBM_BO_IMPORT_FD, &data, + bo_use); + if (!bo->bo.gbm) { + free(bo); return FALSE; } - priv->bo->flags |= AMDGPU_BO_FLAGS_GBM; + bo->flags |= AMDGPU_BO_FLAGS_GBM; #ifdef USE_GLAMOR if (info->use_glamor && - !amdgpu_glamor_create_textured_pixmap(ppix, priv->bo)) { - free(priv->bo); - free(priv); + !amdgpu_glamor_create_textured_pixmap(ppix, bo)) { + amdgpu_bo_unref(&bo); return FALSE; } #endif - amdgpu_set_pixmap_private(ppix, priv); - return TRUE; + ret = amdgpu_set_pixmap_bo(ppix, bo); + /* amdgpu_set_pixmap_bo increments ref_count if it succeeds */ + amdgpu_bo_unref(&bo); + return ret; } pixmap_buffer = amdgpu_gem_bo_open_prime(pAMDGPUEnt->pDev, ihandle, size); |