[Mesa-dev] [PATCH 1/2] winsys/amdgpu: fix a buffer leak in amdgpu_bo_from_handle
Marek Olšák
maraeo at gmail.com
Mon Nov 19 23:24:50 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
Cc: 18.2 18.3 <mesa-stable at lists.freedesktop.org>
---
src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index f49fb47b80e..3ee38b8a79f 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -1303,20 +1303,26 @@ static struct pb_buffer *amdgpu_bo_from_handle(struct radeon_winsys *rws,
simple_mtx_lock(&ws->bo_export_table_lock);
bo = util_hash_table_get(ws->bo_export_table, result.buf_handle);
/* If the amdgpu_winsys_bo instance already exists, bump the reference
* counter and return it.
*/
if (bo) {
p_atomic_inc(&bo->base.reference.count);
simple_mtx_unlock(&ws->bo_export_table_lock);
+
+ /* Release the buffer handle, because we don't need it anymore.
+ * This function is returning an existing buffer, which has its own
+ * handle.
+ */
+ amdgpu_bo_free(result.buf_handle);
return &bo->base;
}
/* Get initial domains. */
r = amdgpu_bo_query_info(result.buf_handle, &info);
if (r)
goto error;
r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
result.alloc_size, 1 << 20, 0, &va, &va_handle,
--
2.17.1
More information about the mesa-dev
mailing list