radv: fix leak of nir from retained shaders
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 5 Apr 2023 14:07:40 +0000 (10:07 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 6 Apr 2023 01:53:28 +0000 (01:53 +0000)
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 <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22317>

src/amd/vulkan/radv_pipeline.c

index 63b595f..fa98b66 100644 (file)
@@ -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) {