winsys/radeon: don't leak the fd when it is 0
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 29 Jul 2015 14:44:32 +0000 (15:44 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sat, 1 Aug 2015 14:44:17 +0000 (15:44 +0100)
Earlier commit added an extra dup(fd) to fix a ZaphodHeads issue.
Although it did not consider the (very unlikely) case where we might end
up with the valid fd == 0.

Fixes: 28dda47ae4d(winsys/radeon: Use dup fd as key in drm-winsys hash
table to fix ZaphodHeads.)

Cc: 10.6 <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com>
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c

index 41f8826c39d23c834e00cc5244634564a5854afe..f7784fb795e4794ca43fe3e950552bcd3f7acfe8 100644 (file)
@@ -493,7 +493,7 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws)
         radeon_surface_manager_free(ws->surf_man);
     }
 
-    if (ws->fd)
+    if (ws->fd >= 0)
         close(ws->fd);
 
     FREE(rws);
@@ -786,7 +786,7 @@ fail:
         ws->kman->destroy(ws->kman);
     if (ws->surf_man)
         radeon_surface_manager_free(ws->surf_man);
-    if (ws->fd)
+    if (ws->fd >= 0)
         close(ws->fd);
 
     FREE(ws);