From 227872571ac57e47777fe1350fe9f5a355b5fbb8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 27 Sep 2013 22:20:04 -0700 Subject: [PATCH] i915, i965: Fix memory leak in intel_miptree_create_for_bo. Fixes "Resource leak" defects reported by Coverity. Signed-off-by: Vinson Lee Reviewed-by: Chad Versace --- 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 66a7a92dc05..f0ad30cc9c9 100644 --- a/src/mesa/drivers/dri/i915/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c @@ -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; diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index bb986bddeb5..884ddefc5cc 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -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; -- 2.30.2