[Mesa-dev] [PATCH] winsys/radeon: don't leak the fd when it is 0

Emil Velikov emil.l.velikov at gmail.com
Wed Jul 29 07:44:32 PDT 2015


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: Mario Kleiner <mario.kleiner.de at gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---

Perhaps we should CC mesa-stable as the offending commit, yet 
considering how unlikely the above case is I'm ambivalent,

-Emil

 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 41f8826..f7784fb 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -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);
-- 
2.4.5



More information about the mesa-dev mailing list