r600g: Fix memory leak.
authorVinson Lee <vlee@freedesktop.org>
Fri, 1 Feb 2013 07:45:13 +0000 (23:45 -0800)
committerVinson Lee <vlee@freedesktop.org>
Sat, 2 Feb 2013 06:52:22 +0000 (22:52 -0800)
Fixes resource leak defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/r600/r600_hw_context.c

index a89f23069d3db6999a0f4403496d741e804fae25..ebcd682bc811f010d18635f2482e17c14e2ac37e 100644 (file)
@@ -201,8 +201,10 @@ int r600_context_add_block(struct r600_context *ctx, const struct r600_reg *reg,
                        /* create block table if it doesn't exist */
                        if (!range->blocks)
                                range->blocks = calloc(1 << HASH_SHIFT, sizeof(void *));
-                       if (!range->blocks)
+                       if (!range->blocks) {
+                               free(block);
                                return -1;
+                       }
 
                        range->blocks[CTX_BLOCK_ID(reg[i + j].offset)] = block;
                }