[Mesa-dev] [PATCH 2/2] winsys/amdgpu: fix a device handle leak in amdgpu_winsys_create
Marek Olšák
maraeo at gmail.com
Mon Nov 19 23:24:51 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_winsys.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index f32bbd9d086..b20d702670d 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -273,20 +273,26 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
simple_mtx_unlock(&dev_tab_mutex);
fprintf(stderr, "amdgpu: amdgpu_device_initialize failed.\n");
return NULL;
}
/* Lookup a winsys if we have already created one for this device. */
ws = util_hash_table_get(dev_tab, dev);
if (ws) {
pipe_reference(NULL, &ws->reference);
simple_mtx_unlock(&dev_tab_mutex);
+
+ /* Release the device handle, because we don't need it anymore.
+ * This function is returning an existing winsys instance, which
+ * has its own device handle.
+ */
+ amdgpu_device_deinitialize(dev);
return &ws->base;
}
/* Create a new winsys. */
ws = CALLOC_STRUCT(amdgpu_winsys);
if (!ws)
goto fail;
ws->dev = dev;
ws->info.drm_major = drm_major;
--
2.17.1
More information about the mesa-dev
mailing list