freedreno: fix potential fd leak in error path

Signed-off-by: Rob Clark <robclark@freedesktop.org>
main
Rob Clark 2016-06-01 14:35:06 -04:00
parent eb846d46bc
commit fe07584e05
1 changed files with 4 additions and 1 deletions

View File

@ -95,9 +95,12 @@ out:
*/
struct fd_device * fd_device_new_dup(int fd)
{
struct fd_device *dev = fd_device_new(dup(fd));
int dup_fd = dup(fd);
struct fd_device *dev = fd_device_new(dup_fd);
if (dev)
dev->closefd = 1;
else
close(dup_fd);
return dev;
}