Skip to content

Commit

Permalink
Don't close negative file descriptors and fix error check
Browse files Browse the repository at this point in the history
  • Loading branch information
Syllo committed Mar 26, 2022
1 parent 499b512 commit 1ef4f24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/extract_gpuinfo_amdgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1ef4f24

Please sign in to comment.