Analogous to previous commit.
Spotted by Coverity (CID
1339868)
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
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)
error:
if (vscreen->dev)
pipe_loader_release(&vscreen->dev, 1);
+ else
+ close(new_fd);
FREE(vscreen);
return NULL;