From e8ff841e983c4b45ff0449796fc17d73a8ca599c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 20 Nov 2022 13:41:55 -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 rsc going out of scope leaks the storage it points to. Fixes: 01964625eb2 ("asahi: Implement agx_resource_from_handle") 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 1e33729..45e99eb 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -174,8 +174,10 @@ agx_resource_from_handle(struct pipe_screen *pscreen, /* We need strides to be aligned. ail asserts this, but we want to fail * gracefully so the app can handle the error. */ - if (rsc->modifier == DRM_FORMAT_MOD_LINEAR && (whandle->stride % 16) != 0) + if (rsc->modifier == DRM_FORMAT_MOD_LINEAR && (whandle->stride % 16) != 0) { + FREE(rsc); return false; + } prsc = &rsc->base; -- 2.7.4