From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, vsementsov@virtuozzo.com,
berrange@redhat.com, kraxel@redhat.com, den@openvz.org
Subject: [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
Date: Tue, 10 Sep 2019 10:59:43 +0300 [thread overview]
Message-ID: <20190910075943.12977-1-vsementsov@virtuozzo.com> (raw)
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)
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
util/qemu-sockets.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 98ff3a1cce..bcc06d0e01 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,
--
2.18.0
next reply other threads:[~2019-09-10 8:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-10 7:59 Vladimir Sementsov-Ogievskiy [this message]
2019-09-10 8:03 ` [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr Daniel P. Berrangé
2019-09-10 13:59 ` Eric Blake
2019-09-11 12:08 ` Vladimir Sementsov-Ogievskiy
2019-09-25 11:33 ` Vladimir Sementsov-Ogievskiy
2019-09-25 13:13 ` Eric Blake
2019-09-10 9:37 ` Stefano Garzarella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190910075943.12977-1-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=berrange@redhat.com \
--cc=den@openvz.org \
--cc=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).