From 2b141bcd25213c16a3e86364cceeca0031970502 Mon Sep 17 00:00:00 2001 From: Maxime Schmitt Date: Sat, 26 Mar 2022 16:15:45 +0100 Subject: [PATCH] Don't close negative file descriptors and fix error check --- src/extract_gpuinfo_amdgpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extract_gpuinfo_amdgpu.c b/src/extract_gpuinfo_amdgpu.c index cbbc278..c620ca7 100644 --- a/src/extract_gpuinfo_amdgpu.c +++ b/src/extract_gpuinfo_amdgpu.c @@ -869,7 +869,7 @@ static void gpuinfo_amdgpu_get_running_processes( goto next; fdinfo_dir = fdopendir(fdinfo_dir_fd); - if (!fdinfo_dir_fd) { + if (!fdinfo_dir) { close(fdinfo_dir_fd); goto next; } @@ -962,7 +962,8 @@ static void gpuinfo_amdgpu_get_running_processes( if (fdinfo_dir) closedir(fdinfo_dir); - close(fd_dir_fd); + if (fd_dir_fd >= 0) + close(fd_dir_fd); close(pid_dir_fd); free(seen_fds);