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-04-20 09:21:33 +0200
commite788b987d866c12af25cee641209a3a5b2d2c107 (patch)
tree286a1af9c81c8f1e06d61fbe969c4d4d68f0a3c3
parent68ee1d57962c81172841459f5eaeefbe5506425e (diff)
radeonsi: fix error paths of si_texture_transfer_map
trans is zero-initialized, but trans->resource is setup immediately so needs to be dereferenced. Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
-rw-r--r--src/gallium/drivers/radeonsi/si_texture.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c
index b41a0d1b925..0a2939bdd16 100644
--- a/src/gallium/drivers/radeonsi/si_texture.c
+++ b/src/gallium/drivers/radeonsi/si_texture.c
@@ -1740,16 +1740,14 @@ static void *si_texture_transfer_map(struct pipe_context *ctx,
if (!si_init_flushed_depth_texture(ctx, &resource, &staging_depth)) {
PRINT_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) {
PRINT_ERR("failed to create a temporary depth texture\n");
- FREE(trans);
- return NULL;
+ goto fail_trans;
}
si_copy_region_with_blit(ctx, temp, 0, 0, 0, 0, texture, level, box);
@@ -1767,8 +1765,7 @@ static void *si_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)) {
PRINT_ERR("failed to create temporary texture to hold untiled copy\n");
- FREE(trans);
- return NULL;
+ goto fail_trans;
}
si_blit_decompress_depth(ctx, rtex, staging_depth,
@@ -1797,8 +1794,7 @@ static void *si_texture_transfer_map(struct pipe_context *ctx,
staging = (struct r600_texture*)ctx->screen->resource_create(ctx->screen, &resource);
if (!staging) {
PRINT_ERR("failed to create temporary texture to hold untiled copy\n");
- FREE(trans);
- return NULL;
+ goto fail_trans;
}
trans->staging = &staging->resource;
@@ -1821,14 +1817,17 @@ static void *si_texture_transfer_map(struct pipe_context *ctx,
buf = &rtex->resource;
}
- if (!(map = si_buffer_map_sync_with_rings(sctx, buf, usage))) {
- r600_resource_reference(&trans->staging, NULL);
- FREE(trans);
- return NULL;
- }
+ if (!(map = si_buffer_map_sync_with_rings(sctx, 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 si_texture_transfer_unmap(struct pipe_context *ctx,