diff options
author | Rob Clark <[email protected]> | 2013-09-27 15:35:19 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2013-10-24 20:21:08 -0400 |
commit | 0a1e4361e8edd0d0bb5d22be9527ab40080c66e7 (patch) | |
tree | 1305edeb211bd58a56dc9ed9328ee044250d4b95 | |
parent | 2b2fc03beb6ff6a5e87f16afbd687ac9addc3824 (diff) |
freedreno/resource: fail more gracefully
Fail more gracefully when buffer allocation/import fails.
Signed-off-by: Rob Clark <[email protected]>
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_resource.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 197a5a00e09..bd8c6cb9907 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -157,7 +157,8 @@ fd_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc) { struct fd_resource *rsc = fd_resource(prsc); - fd_bo_del(rsc->bo); + if (rsc->bo) + fd_bo_del(rsc->bo); FREE(rsc); } @@ -243,8 +244,13 @@ fd_resource_create(struct pipe_screen *pscreen, size = setup_slices(rsc); realloc_bo(rsc, size); + if (!rsc->bo) + goto fail; return prsc; +fail: + fd_resource_destroy(pscreen, prsc); + return NULL; } /** @@ -277,6 +283,8 @@ fd_resource_from_handle(struct pipe_screen *pscreen, prsc->screen = pscreen; rsc->bo = fd_screen_bo_from_handle(pscreen, handle, &slice->pitch); + if (!rsc->bo) + goto fail; rsc->base.vtbl = &fd_resource_vtbl; rsc->cpp = util_format_get_blocksize(tmpl->format); @@ -285,6 +293,10 @@ fd_resource_from_handle(struct pipe_screen *pscreen, assert(rsc->cpp); return prsc; + +fail: + fd_resource_destroy(pscreen, prsc); + return NULL; } static bool render_blit(struct pipe_context *pctx, struct pipe_blit_info *info); |