aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2019-09-10 10:59:43 +0300
committerEric Blake <eblake@redhat.com>2019-09-25 08:15:44 -0500
commitda5e1169183ca6eb6fb470dc32ed1bfc24d1d406 (patch)
treedb51ff2e33f0446f3db5758999e16f1c49477451 /util
parent506902c6fa80210b002e30ff33794bfc718b15c6 (diff)
downloadqemu-da5e1169183ca6eb6fb470dc32ed1bfc24d1d406.zip
qemu-da5e1169183ca6eb6fb470dc32ed1bfc24d1d406.tar.gz
qemu-da5e1169183ca6eb6fb470dc32ed1bfc24d1d406.tar.bz2
util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
In "if (saddr->keep_alive) {" we may already be on error path, with invalid sock < 0. Fix it by returning error earlier. Reported-by: Coverity (CID 1405300) Fixes: aec21d31756cbd Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20190910075943.12977-1-vsementsov@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/qemu-sockets.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 98ff3a1..bcc06d0 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -461,12 +461,13 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
}
}
+ freeaddrinfo(res);
+
if (sock < 0) {
error_propagate(errp, local_err);
+ return sock;
}
- freeaddrinfo(res);
-
if (saddr->keep_alive) {
int val = 1;
int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,