From 0a1e4361e8edd0d0bb5d22be9527ab40080c66e7 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Fri, 27 Sep 2013 15:35:19 -0400 Subject: [PATCH] freedreno/resource: fail more gracefully Fail more gracefully when buffer allocation/import fails. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_resource.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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); -- 2.30.2