Module: Mesa
Branch: main
Commit: a73c28fdce7c3bbeb3340303209d80a208759206
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a73c28fdce7c3bbeb3340303209d80a208759206

Author: Mike Blumenkrantz <[email protected]>
Date:   Wed Apr  5 10:07:40 2023 -0400

radv: fix leak of nir from retained shaders

if shaders are found in the app cache above, execution will goto done:
and the nir must still be freed

Fixes: 03d2bd6042d ("radv: ensure to retain NIR shaders for GPL libs found in 
the cache")

fixes #8786

Reviewed-by: Samuel Pitoiset <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22317>

---

 src/amd/vulkan/radv_pipeline.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 63b595fada4..fa98b66de2a 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -3421,12 +3421,13 @@ radv_graphics_pipeline_compile(struct 
radv_graphics_pipeline *pipeline,
          if (radv_can_dump_shader_stats(device, stages[i].nir) && 
pipeline->base.shaders[i]) {
             radv_dump_shader_stats(device, &pipeline->base, 
pipeline->base.shaders[i], i, stderr);
          }
-
-         ralloc_free(stages[i].nir);
       }
    }
 
 done:
+   for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) {
+      ralloc_free(stages[i].nir);
+   }
    pipeline_feedback.duration = os_time_get_nano() - pipeline_start;
 
    if (creation_feedback) {

Reply via email to