summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2018-01-16 14:38:00 +0100
committerNicolai Hähnle <nicolai.haehnle@amd.com>2018-01-16 20:15:32 +0100
commitda3bdb4fec60be58a1df8fa0451ff21daed90021 (patch)
tree4e21a16554fe2372a5f3452526cda2644dddda30
parent507651df680704593148377c6c171e9592105d8e (diff)
radeonsi: fix failure paths of r600_texture_transfer_map
trans is zero-initialized, but trans->resource is setup immediately so needs to be dereferenced.
-rw-r--r--src/gallium/drivers/radeon/r600_texture.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index ecc70280b4..c1f55b47bb 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1719,16 +1719,14 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
if (!si_init_flushed_depth_texture(ctx, &resource, &staging_depth)) {
R600_ERR("failed to create temporary texture to hold untiled copy\n");
- FREE(trans);
- return NULL;
+ goto fail_trans;
}
if (usage & PIPE_TRANSFER_READ) {
struct pipe_resource *temp = ctx->screen->resource_create(ctx->screen, &resource);
if (!temp) {
R600_ERR("failed to create a temporary depth texture\n");
- FREE(trans);
- return NULL;
+ goto fail_trans;
}
r600_copy_region_with_blit(ctx, temp, 0, 0, 0, 0, texture, level, box);
@@ -1746,8 +1744,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
/* XXX: when discard is true, no need to read back from depth texture */
if (!si_init_flushed_depth_texture(ctx, texture, &staging_depth)) {
R600_ERR("failed to create temporary texture to hold untiled copy\n");
- FREE(trans);
- return NULL;
+ goto fail_trans;
}
rctx->blit_decompress_depth(ctx, rtex, staging_depth,
@@ -1776,8 +1773,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
staging = (struct r600_texture*)ctx->screen->resource_create(ctx->screen, &resource);
if (!staging) {
R600_ERR("failed to create temporary texture to hold untiled copy\n");
- FREE(trans);
- return NULL;
+ goto fail_trans;
}
trans->staging = &staging->resource;
@@ -1800,14 +1796,17 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
buf = &rtex->resource;
}
- if (!(map = si_buffer_map_sync_with_rings(rctx, buf, usage))) {
- r600_resource_reference(&trans->staging, NULL);
- FREE(trans);
- return NULL;
- }
+ if (!(map = si_buffer_map_sync_with_rings(rctx, buf, usage)))
+ goto fail_trans;
*ptransfer = &trans->b.b;
return map + offset;
+
+fail_trans:
+ r600_resource_reference(&trans->staging, NULL);
+ pipe_resource_reference(&trans->b.b.resource, NULL);
+ FREE(trans);
+ return NULL;
}
static void r600_texture_transfer_unmap(struct pipe_context *ctx,