winsys/radeon: don't leak the fd when it is 0

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>
This commit is contained in:
Emil Velikov
2015-07-29 15:44:32 +01:00
parent eb3e2562a4
commit 1307be519b
@@ -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);