From 5f0674075e1ded5e94138b2083f0b13ad0bf1548 Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Mon, 28 Sep 2020 08:57:07 +0000 Subject: [PATCH] util: Improper use of negative value (NEGATIVE_RETURNS) 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 --- criu/util.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/criu/util.c b/criu/util.c index c610da7b3a..a096f3c196 100644 --- a/criu/util.c +++ b/criu/util.c @@ -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; }