summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/amdgpu/drm
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-05-05 22:08:39 -0500
committerNicolai Hähnle <[email protected]>2016-05-17 15:28:40 -0500
commitd464bfd12abbd8563ed5885da717512a0e032eb7 (patch)
tree8ebcaa87bbf310d271a2af42d41b45e03136c808 /src/gallium/winsys/amdgpu/drm
parentfef08af99c7e83f100a5ae25f2798131c278d841 (diff)
winsys/amdgpu: cleanup error handling in amdgpu_ctx_create
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/winsys/amdgpu/drm')
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_cs.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
index 8a801f087fb..ffb0b7be58b 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
@@ -135,14 +135,16 @@ static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *ws)
struct amdgpu_bo_alloc_request alloc_buffer = {};
amdgpu_bo_handle buf_handle;
+ if (!ctx)
+ return NULL;
+
ctx->ws = amdgpu_winsys(ws);
ctx->refcount = 1;
r = amdgpu_cs_ctx_create(ctx->ws->dev, &ctx->ctx);
if (r) {
fprintf(stderr, "amdgpu: amdgpu_cs_ctx_create failed. (%i)\n", r);
- FREE(ctx);
- return NULL;
+ goto error_create;
}
alloc_buffer.alloc_size = ctx->ws->info.gart_page_size;
@@ -152,24 +154,27 @@ static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *ws)
r = amdgpu_bo_alloc(ctx->ws->dev, &alloc_buffer, &buf_handle);
if (r) {
fprintf(stderr, "amdgpu: amdgpu_bo_alloc failed. (%i)\n", r);
- amdgpu_cs_ctx_free(ctx->ctx);
- FREE(ctx);
- return NULL;
+ goto error_user_fence_alloc;
}
r = amdgpu_bo_cpu_map(buf_handle, (void**)&ctx->user_fence_cpu_address_base);
if (r) {
fprintf(stderr, "amdgpu: amdgpu_bo_cpu_map failed. (%i)\n", r);
- amdgpu_bo_free(buf_handle);
- amdgpu_cs_ctx_free(ctx->ctx);
- FREE(ctx);
- return NULL;
+ goto error_user_fence_map;
}
memset(ctx->user_fence_cpu_address_base, 0, alloc_buffer.alloc_size);
ctx->user_fence_bo = buf_handle;
return (struct radeon_winsys_ctx*)ctx;
+
+error_user_fence_map:
+ amdgpu_bo_free(buf_handle);
+error_user_fence_alloc:
+ amdgpu_cs_ctx_free(ctx->ctx);
+error_create:
+ FREE(ctx);
+ return NULL;
}
static void amdgpu_ctx_destroy(struct radeon_winsys_ctx *rwctx)