Commit 4fa33e45 authored by Christian König's avatar Christian König Committed by Michel Dänzer
Browse files

amdgpu: make sure to set CLOEXEC on duplicated FDs



Otherwise we leak file descriptors into child processes.
Signed-off-by: Christian König's avatarChristian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Junwei Zhang's avatarJunwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <michel.daenzer@amd.com>
parent 7e450102
......@@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "xf86drm.h"
#include "amdgpu_drm.h"
......@@ -205,7 +206,7 @@ int amdgpu_device_initialize(int fd,
return r;
}
if ((flag_auth) && (!flag_authexist)) {
dev->flink_fd = dup(fd);
dev->flink_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
}
*major_version = dev->major_version;
*minor_version = dev->minor_version;
......@@ -239,7 +240,7 @@ int amdgpu_device_initialize(int fd,
goto cleanup;
}
dev->fd = dup(fd);
dev->fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
dev->flink_fd = dev->fd;
dev->major_version = version->version_major;
dev->minor_version = version->version_minor;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment