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: aec21d3175
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>
This commit is contained in:
parent
506902c6fa
commit
da5e116918
@ -461,12 +461,13 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
freeaddrinfo(res);
|
||||||
|
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
freeaddrinfo(res);
|
|
||||||
|
|
||||||
if (saddr->keep_alive) {
|
if (saddr->keep_alive) {
|
||||||
int val = 1;
|
int val = 1;
|
||||||
int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
|
int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
|
||||||
|
Loading…
Reference in New Issue
Block a user