Analogous to previous commit.
Spotted by Coverity (CID
1339866)
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
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)
out_no_screen:
if (xa->dev)
pipe_loader_release(&xa->dev, 1);
+ fd = -1;
+ out_no_fd:
+ close(fd);
free(xa);
return NULL;
}