From 7e6478e7d4f2c4b607069bf488d57089a9d3244b Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Tue, 9 May 2017 12:04:52 -0700 Subject: Check the return value of fcntl in qemu_set_cloexec Assert that the return value is not an error. This issue was found by Coverity. CID: 1374831 Signed-off-by: Stefano Stabellini CC: groug@kaod.org CC: pbonzini@redhat.com CC: Eric Blake Message-Id: <1494356693-13190-2-git-send-email-sstabellini@kernel.org> Signed-off-by: Paolo Bonzini --- util/oslib-posix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 7e28c16..048d40d 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -182,7 +182,9 @@ void qemu_set_cloexec(int fd) { int f; f = fcntl(fd, F_GETFD); - fcntl(fd, F_SETFD, f | FD_CLOEXEC); + assert(f != -1); + f = fcntl(fd, F_SETFD, f | FD_CLOEXEC); + assert(f != -1); } /* -- cgit v1.1