Mesa (main): radeonsi: properly destroy buffers on failure

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 19 17:44:52 UTC 2021


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun Oct 17 08:20:12 2021 -0400

radeonsi: properly destroy buffers on failure

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13400>

---

 src/gallium/drivers/radeonsi/si_buffer.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_buffer.c b/src/gallium/drivers/radeonsi/si_buffer.c
index 0867c98f59a..027304a3769 100644
--- a/src/gallium/drivers/radeonsi/si_buffer.c
+++ b/src/gallium/drivers/radeonsi/si_buffer.c
@@ -591,13 +591,13 @@ static struct pipe_resource *si_buffer_create(struct pipe_screen *screen,
    if (templ->flags & PIPE_RESOURCE_FLAG_SPARSE)
       buf->flags |= RADEON_FLAG_SPARSE;
 
+   buf->b.buffer_id_unique = util_idalloc_mt_alloc(&sscreen->buffer_ids);
+
    if (!si_alloc_resource(sscreen, buf)) {
-      threaded_resource_deinit(&buf->b.b);
-      FREE_CL(buf);
+      si_resource_destroy(screen, &buf->b.b);
       return NULL;
    }
 
-   buf->b.buffer_id_unique = util_idalloc_mt_alloc(&sscreen->buffer_ids);
    return &buf->b.b;
 }
 
@@ -639,17 +639,17 @@ static struct pipe_resource *si_buffer_from_user_memory(struct pipe_screen *scre
    util_range_add(&buf->b.b, &buf->valid_buffer_range, 0, templ->width0);
    util_range_add(&buf->b.b, &buf->b.valid_buffer_range, 0, templ->width0);
 
+   buf->b.buffer_id_unique = util_idalloc_mt_alloc(&sscreen->buffer_ids);
+
    /* Convert a user pointer to a buffer. */
    buf->buf = ws->buffer_from_ptr(ws, user_memory, templ->width0);
    if (!buf->buf) {
-      threaded_resource_deinit(&buf->b.b);
-      FREE_CL(buf);
+      si_resource_destroy(screen, &buf->b.b);
       return NULL;
    }
 
    buf->gpu_address = ws->buffer_get_virtual_address(buf->buf);
    buf->memory_usage_kb = templ->width0 / 1024;
-   buf->b.buffer_id_unique = util_idalloc_mt_alloc(&sscreen->buffer_ids);
    return &buf->b.b;
 }
 



More information about the mesa-commit mailing list