From ff6f11acdc611e1ce6fb568791624d11c529e88f Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Sun, 14 Mar 2021 19:31:48 +0100 Subject: [PATCH] radeonsi: fix leak when the in-memory cache is full MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the hw_binary is not put in the in-memory cache it must be freed. Fixes: 8283ed65cfd ("radeonsi: Limit the size of the in-memory shader cache") Signed-off-by: Axel Davy Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_state_shaders.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index df947f3ec0b..38b1f94f6e7 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -255,6 +255,9 @@ void si_shader_cache_insert_shader(struct si_screen *sscreen, unsigned char ir_s disk_cache_compute_key(sscreen->disk_shader_cache, ir_sha1_cache_key, 20, key); disk_cache_put(sscreen->disk_shader_cache, key, hw_binary, *((uint32_t *)hw_binary), NULL); } + + if (memory_cache_full) + FREE(hw_binary); } bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20],