[Mesa-dev] [PATCH mesa] i965: fix resource leak
Eric Engestrom
eric at engestrom.ch
Sun Jun 10 17:42:45 UTC 2018
Coverity ID: 1436909
Fixes: 3352f2d746d3959b22ca4 "i965: Create multiple miptrees for planar YUV images"
Signed-off-by: Eric Engestrom <eric at engestrom.ch>
---
src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 69024c0678bedc3a6d2c..d678d615b9080e5f2c7f 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -907,8 +907,9 @@ miptree_create_for_planar_image(struct brw_context *brw,
{
const struct intel_image_format *f = image->planar_format;
struct intel_mipmap_tree *planar_mt = NULL;
+ int i;
- for (int i = 0; i < f->nplanes; i++) {
+ for (i = 0; i < f->nplanes; i++) {
const int index = f->planes[i].buffer_index;
const uint32_t dri_format = f->planes[i].dri_format;
const mesa_format format = driImageFormatToGLFormat(dri_format);
@@ -928,7 +929,7 @@ miptree_create_for_planar_image(struct brw_context *brw,
tiling,
MIPTREE_CREATE_NO_AUX);
if (mt == NULL)
- return NULL;
+ goto fail;
mt->target = target;
@@ -941,6 +942,13 @@ miptree_create_for_planar_image(struct brw_context *brw,
planar_mt->drm_modifier = image->modifier;
return planar_mt;
+
+fail:
+ while (i--) {
+ intel_miptree_release(&planar_mt->plane[i]);
+ }
+ intel_miptree_release(&planar_mt);
+ return NULL;
}
static bool
--
Cheers,
Eric
More information about the mesa-dev
mailing list