summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2015-11-23 20:26:58 +0000
committerEmil Velikov <[email protected]>2015-11-29 14:40:26 +0000
commit151290c1548052fa4e4d625ba99ad63919467e96 (patch)
tree7a452c232bfec0d6937151c0068e5cb64ac6ab22 /src/gallium
parentfe71059388ebb797255d5d5f7191f300343c6e3c (diff)
auxiliary/vl/drm: fd management cleanups
Analogous to previous commit. Spotted by Coverity (CID 1339868) Cc: [email protected] Signed-off-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/vl/vl_winsys_drm.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c
index f993e2c7727..6d9d947588c 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -41,12 +41,16 @@ struct vl_screen *
vl_drm_screen_create(int fd)
{
struct vl_screen *vscreen;
+ int new_fd = -1;
vscreen = CALLOC_STRUCT(vl_screen);
if (!vscreen)
return NULL;
- if (pipe_loader_drm_probe_fd(&vscreen->dev, dup(fd)))
+ if (fd < 0 || (new_fd = dup(fd)) < 0)
+ goto error;
+
+ if (pipe_loader_drm_probe_fd(&vscreen->dev, new_fd))
vscreen->pscreen = pipe_loader_create_screen(vscreen->dev);
if (!vscreen->pscreen)
@@ -63,6 +67,8 @@ vl_drm_screen_create(int fd)
error:
if (vscreen->dev)
pipe_loader_release(&vscreen->dev, 1);
+ else
+ close(new_fd);
FREE(vscreen);
return NULL;