Mesa (main): zink: Fix memory leak on error path.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 4 22:52:59 UTC 2022


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

Author: Vinson Lee <vlee at freedesktop.org>
Date:   Fri Apr 29 22:57:02 2022 -0700

zink: Fix memory leak on error path.

Fix defect reported by Coverity Scan.

Resource leak (RESOURCE_LEAK)
leaked_storage: Variable sampler_view going out of scope leaks the storage it points to.

Fixes: 625457caafb ("zink: handle swapchain acquire failures more directly")
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16258>

---

 src/gallium/drivers/zink/zink_context.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index f9d8808fbe0..a611ea57556 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -807,8 +807,10 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
       }
 
       if (zink_is_swapchain(res)) {
-         if (!zink_kopper_acquire(ctx, res, UINT64_MAX))
+         if (!zink_kopper_acquire(ctx, res, UINT64_MAX)) {
+            FREE_CL(sampler_view);
             return NULL;
+         }
       }
 
       ivci = create_ivci(screen, res, &templ, state->target);



More information about the mesa-commit mailing list