Module: Mesa
Branch: staging/22.2
Commit: c46d419506dc8d32b567721b60fa2c20645e1c5d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c46d419506dc8d32b567721b60fa2c20645e1c5d

Author: Kenneth Graunke <[email protected]>
Date:   Wed Apr 27 01:35:02 2022 -0700

crocus: Fix memory leaks on iris_resource_create failure paths

We've already allocated the pipe resource, so we ought to free it
before returning.

Fixes: d8a38edc48e ("crocus: fail resource allocation properly.")
Fixes: f3630548f1d ("crocus: initial gallium driver for Intel gfx 4-7")
Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18311>
(cherry picked from commit 6c7916b7f665db7f5af929ed0f64206d70fccc56)

---

 .pick_status.json                            | 2 +-
 src/gallium/drivers/crocus/crocus_resource.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 17b2aa4a1c8..b0d35119520 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -346,7 +346,7 @@
         "description": "crocus: Fix memory leaks on iris_resource_create 
failure paths",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "d8a38edc48e5567e5f0205b7347761e3d05a4bda"
     },
diff --git a/src/gallium/drivers/crocus/crocus_resource.c 
b/src/gallium/drivers/crocus/crocus_resource.c
index c35b63079c2..95df0b02c48 100644
--- a/src/gallium/drivers/crocus/crocus_resource.c
+++ b/src/gallium/drivers/crocus/crocus_resource.c
@@ -695,12 +695,12 @@ crocus_resource_create_with_modifiers(struct pipe_screen 
*pscreen,
    if (templ->usage == PIPE_USAGE_STAGING &&
        templ->bind == PIPE_BIND_DEPTH_STENCIL &&
        devinfo->ver < 6)
-      return NULL;
+      goto fail;
 
    const bool isl_surf_created_successfully =
       crocus_resource_configure_main(screen, res, templ, modifier, 0);
    if (!isl_surf_created_successfully)
-      return NULL;
+      goto fail;
 
    const char *name = "miptree";
 

Reply via email to