i915, i965: Fix memory leak in intel_miptree_create_for_bo.
authorVinson Lee <vlee@freedesktop.org>
Sat, 28 Sep 2013 05:20:04 +0000 (22:20 -0700)
committerChad Versace <chad.versace@linux.intel.com>
Mon, 11 Nov 2013 21:11:07 +0000 (13:11 -0800)
Fixes "Resource leak" defects reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
src/mesa/drivers/dri/i915/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.c

index 66a7a92dc05cc12fb48ffb8affe0b0020ab18c22..f0ad30cc9c9b9cb4561840eafbb870925399c53f 100644 (file)
@@ -264,8 +264,10 @@ intel_miptree_create_for_bo(struct intel_context *intel,
                                     0, 0,
                                     width, height, 1,
                                     true);
-   if (!mt)
+   if (!mt) {
+      free(region);
       return mt;
+   }
 
    region->cpp = mt->cpp;
    region->width = width;
index bb986bddeb594937282b8784918c8553324d9204..884ddefc5cc9bc9ee60214e263a68c9772793a64 100644 (file)
@@ -636,8 +636,10 @@ intel_miptree_create_for_bo(struct brw_context *brw,
                                     0, 0,
                                     width, height, 1,
                                     true, 0 /* num_samples */);
-   if (!mt)
+   if (!mt) {
+      free(region);
       return mt;
+   }
 
    region->cpp = mt->cpp;
    region->width = width;