[Mesa-dev] [PATCH] i915, i965: Fix memory leak in intel_miptree_create_for_bo.

Vinson Lee vlee at freedesktop.org
Thu Jun 27 22:26:49 PDT 2013


Fixes "Resource leak" defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 src/mesa/drivers/dri/i915/intel_mipmap_tree.c | 4 +++-
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
index 058cfbe..f2c2092 100644
--- a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
@@ -654,8 +654,10 @@ intel_miptree_create_for_bo(struct intel_context *intel,
                                     0, 0,
                                     width, height, 1,
                                     true, 0 /* num_samples */);
-   if (!mt)
+   if (!mt) {
+      free(region);
       return mt;
+   }
 
    region->cpp = mt->cpp;
    region->width = width;
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 058cfbe..f2c2092 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -654,8 +654,10 @@ intel_miptree_create_for_bo(struct intel_context *intel,
                                     0, 0,
                                     width, height, 1,
                                     true, 0 /* num_samples */);
-   if (!mt)
+   if (!mt) {
+      free(region);
       return mt;
+   }
 
    region->cpp = mt->cpp;
    region->width = width;
-- 
1.8.3.1



More information about the mesa-dev mailing list