winsys/amdgpu: fix a device handle leak in amdgpu_winsys_create
authorMarek Olšák <marek.olsak@amd.com>
Mon, 19 Nov 2018 23:17:40 +0000 (18:17 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 23 Nov 2018 22:08:44 +0000 (17:08 -0500)
Cc: 18.2 18.3 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c

index f32bbd9d08658795b24018b44e1301e7094985ab..b20d702670d9e6c7c2883d98e659b26920acdc98 100644 (file)
@@ -280,6 +280,12 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
    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;
    }