Mesa (staging/20.2): zink: reorder create_stream_output_target to fix failure case leak
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Sep 24 22:19:10 UTC 2020
Module: Mesa
Branch: staging/20.2
Commit: a2f1b6d268bc2afca357a6bf3c9aebc763840f46
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a2f1b6d268bc2afca357a6bf3c9aebc763840f46
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Tue Aug 25 09:39:06 2020 -0400
zink: reorder create_stream_output_target to fix failure case leak
the previous version of this leaked a reference to the streamout buffer here
thanks to deltragon on my blog for pointing this out!
Fixes: 37778fcd9a35 ("zink: implement transform feedback support to finish off opengl 3.0")
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6457>
(cherry picked from commit 7971918924dd84c2f33a5b7f0a8bf0c23ed994d8)
---
.pick_status.json | 2 +-
src/gallium/drivers/zink/zink_context.c | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 0a8f1ba422d..809f5ee3f32 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -13,7 +13,7 @@
"description": "zink: reorder create_stream_output_target to fix failure case leak",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "37778fcd9a352430af0cd3b28a8776479a7c8380"
},
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 792027ceb93..935c2cadf33 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1048,12 +1048,6 @@ zink_create_stream_output_target(struct pipe_context *pctx,
if (!t)
return NULL;
- t->base.reference.count = 1;
- t->base.context = pctx;
- pipe_resource_reference(&t->base.buffer, pres);
- t->base.buffer_offset = buffer_offset;
- t->base.buffer_size = buffer_size;
-
/* using PIPE_BIND_CUSTOM here lets us create a custom pipe buffer resource,
* which allows us to differentiate and use VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT
* as we must for this case
@@ -1064,6 +1058,12 @@ zink_create_stream_output_target(struct pipe_context *pctx,
return NULL;
}
+ t->base.reference.count = 1;
+ t->base.context = pctx;
+ pipe_resource_reference(&t->base.buffer, pres);
+ t->base.buffer_offset = buffer_offset;
+ t->base.buffer_size = buffer_size;
+
return &t->base;
}
More information about the mesa-commit
mailing list