Skip to content

Commit

Permalink
util: Improper use of negative value (NEGATIVE_RETURNS)
Browse files Browse the repository at this point in the history
CID 192968 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
 dup(fd) is passed to a parameter that cannot be negative. [show details]

Signed-off-by: Adrian Reber <areber@redhat.com>
  • Loading branch information
adrianreber authored and avagin committed Oct 20, 2020
1 parent ca7a832 commit 5f06740
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion criu/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,14 @@ void close_proc(void)

int set_proc_fd(int fd)
{
if (install_service_fd(PROC_FD_OFF, dup(fd)) < 0)
int _fd;

_fd = dup(fd);
if (_fd < 0) {
pr_perror("dup() failed");
return -1;
}
if (install_service_fd(PROC_FD_OFF, _fd) < 0)
return -1;
return 0;
}
Expand Down

0 comments on commit 5f06740

Please sign in to comment.