From d6d772d3d162f9cee1f64fc7d0c87b63f7d1c9d4 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 20 Nov 2022 14:08:50 -0800 Subject: [PATCH] asahi: Fix memory leak on error path. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix defect reported by Coverity Scan. Resource leak (RESOURCE_LEAK) leaked_storage: Variable nresource going out of scope leaks the storage it points to. Fixes: 7522f4f7147 ("asahi: Make resource creation code modifier-aware") Signed-off-by: Vinson Lee Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 45e99eb..8e9a04b 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -392,8 +392,10 @@ agx_resource_create_with_modifiers(struct pipe_screen *screen, nresource->modifier = agx_select_modifier_from_list(nresource, modifiers, count); /* There may not be a matching modifier, bail if so */ - if (nresource->modifier == DRM_FORMAT_MOD_INVALID) + if (nresource->modifier == DRM_FORMAT_MOD_INVALID) { + free(nresource); return NULL; + } } else { nresource->modifier = agx_select_best_modifier(nresource); -- 2.7.4