aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2015-11-23 20:26:57 +0000
committerEmil Velikov <[email protected]>2015-11-30 00:13:23 +0000
commitef6769f18f16c11ff1fa7cb50a8713b8cbaf3a12 (patch)
treef3091bd099beb4c17af30636dd59228972b2ce1f
parenta71db1c46e12583cd2ecca9ad5258d8a1f4a2a03 (diff)
st/xa: fd management cleanups
Analogous to previous commit. Spotted by Coverity (CID 1339866) Cc: [email protected] Signed-off-by: Emil Velikov <[email protected]> (cherry picked from commit fe71059388ebb797255d5d5f7191f300343c6e3c)
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index faa630c144b..d57464b7d60 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -152,11 +152,15 @@ xa_tracker_create(int drm_fd)
struct xa_tracker *xa = calloc(1, sizeof(struct xa_tracker));
enum xa_surface_type stype;
unsigned int num_formats;
+ int fd = -1;
if (!xa)
return NULL;
- if (pipe_loader_drm_probe_fd(&xa->dev, dup(drm_fd)))
+ if (drm_fd < 0 || (fd = dup(drm_fd)) < 0)
+ goto out_no_fd;
+
+ if (pipe_loader_drm_probe_fd(&xa->dev, fd))
xa->screen = pipe_loader_create_screen(xa->dev);
if (!xa->screen)
@@ -208,6 +212,9 @@ xa_tracker_create(int drm_fd)
out_no_screen:
if (xa->dev)
pipe_loader_release(&xa->dev, 1);
+ fd = -1;
+ out_no_fd:
+ close(fd);
free(xa);
return NULL;
}