Skip to content

Commit

Permalink
criu: don't call close() for a negative value
Browse files Browse the repository at this point in the history
CID 73358 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
8. negative_returns: sk is passed to a parameter that cannot be negative. [hide details]
  • Loading branch information
avagin committed Feb 16, 2018
1 parent 8feb217 commit f82c078
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions criu/kerndat.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ int kerndat_fdinfo_has_lock()

exit_code = 0;
out:
close(pfd);
close_safe(&pfd);
close(fd);

return exit_code;
Expand Down Expand Up @@ -770,7 +770,7 @@ int kerndat_has_ns_get_parent(void)
p_ns = ioctl(ns, NS_GET_PARENT);
if (p_ns >= 0 || errno == EPERM) {
kdat.has_ns_get_parent = true;
close(p_ns);
close_safe(&p_ns);
}

close(ns);
Expand Down
2 changes: 1 addition & 1 deletion criu/sk-netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static int open_netlink_sk(struct file_desc *d, int *new_fd)
*new_fd = sk;
return 0;
err:
close(sk);
close_safe(&sk);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion criu/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ int run_tcp_server(bool daemon_mode, int *ask, int cfd, int sk)

return 0;
out:
close(sk);
close_safe(&sk);
return -1;
}

Expand Down

0 comments on commit f82c078

Please sign in to comment.