]> Git Repo - qemu.git/commitdiff
util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
authorVladimir Sementsov-Ogievskiy <[email protected]>
Tue, 10 Sep 2019 07:59:43 +0000 (10:59 +0300)
committerEric Blake <[email protected]>
Wed, 25 Sep 2019 13:15:44 +0000 (08:15 -0500)
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 <[email protected]>
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <20190910075943[email protected]>
Reviewed-by: Daniel P. BerrangĂ© <[email protected]>
Signed-off-by: Eric Blake <[email protected]>
util/qemu-sockets.c

index 98ff3a1cce6479abbdf509d23116062ab6f21983..bcc06d0e01c783f55f123cc88ca8d24a47e76e35 100644 (file)
@@ -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,
This page took 0.027928 seconds and 4 git commands to generate.