gallium/targets/d3dadapter9: Free card device
authorAxel Davy <axel.davy@ens.fr>
Sat, 24 Jan 2015 16:58:28 +0000 (17:58 +0100)
committerAxel Davy <axel.davy@ens.fr>
Thu, 5 Feb 2015 23:07:20 +0000 (00:07 +0100)
The drm fd wasn't released, causing a crash
for wine tests on nouveau, which seems to have
a bug when a lot of device descriptors are open.

Reviewed-by: Tiziano Bacocco <tizbac2@gmail.com>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/targets/d3dadapter9/drm.c

index f054654d96e8ce5597f1ac4c4fb8168d11838d40..cb0c48f12bb0a02c454738b80527d9887fa4b1c9 100644 (file)
@@ -74,27 +74,28 @@ struct d3dadapter9drm_context
 {
     struct d3dadapter9_context base;
     struct pipe_loader_device *dev, *swdev;
+    int fd;
 };
 
 static void
 drm_destroy( struct d3dadapter9_context *ctx )
 {
+    struct d3dadapter9drm_context *drm = (struct d3dadapter9drm_context *)ctx;
+
     if (ctx->ref)
         ctx->ref->destroy(ctx->ref);
     /* because ref is a wrapper around hal, freeing ref frees hal too. */
     else if (ctx->hal)
         ctx->hal->destroy(ctx->hal);
-#if !GALLIUM_STATIC_TARGETS
-    {
-        struct d3dadapter9drm_context *drm = (struct d3dadapter9drm_context *)ctx;
 
-        if (drm->swdev)
-            pipe_loader_release(&drm->swdev, 1);
-        if (drm->dev)
-            pipe_loader_release(&drm->dev, 1);
-    }
+#if !GALLIUM_STATIC_TARGETS
+    if (drm->swdev)
+        pipe_loader_release(&drm->swdev, 1);
+    if (drm->dev)
+        pipe_loader_release(&drm->dev, 1);
 #endif
 
+    close(drm->fd);
     FREE(ctx);
 }
 
@@ -235,6 +236,7 @@ drm_create_adapter( int fd,
     ctx->base.destroy = drm_destroy;
 
     fd = loader_get_user_preferred_fd(fd, &different_device);
+    ctx->fd = fd;
     ctx->base.linear_framebuffer = !!different_device;
 
 #if GALLIUM_STATIC_TARGETS