Skip to contentSkip to conversation

util/qemu-sockets: fix keep_alive handling in inet_connect_saddr

PATCH In review Vladimir Sementsov-Ogievskiy 4 participants 7 messages Sep 10, 2019 – Sep 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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)
---
 util/qemu-sockets.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
util/qemu-sockets.c +3 -2
index 98ff3a1cce..bcc06d0e01 100644
@@ -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,
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Vladimir Sementsov-Ogievskiy

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)
---
 util/qemu-sockets.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Reviewed-by on v1 1/1
#6 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 9 lines · Vladimir Sementsov-Ogievskiy

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)
---
 util/qemu-sockets.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
#2 lore raw
In reply to Daniel P. Berrangé
Quoted 4 lines · Daniel P. Berrangé
Quoted 3 lines · Vladimir Sementsov-Ogievskiy

In "if (saddr->keep_alive) {" we may already be on error path, with invalid sock < 0. Fix it by returning error earlier.

Quoted 8 lines
Quoted 6 lines
Reported-by Coverity (CID 1405300)
---
 util/qemu-sockets.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Thanks. Will queue through my NBD tree, since that's where the original problem was introduced.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#3 lore raw
Quoted 12 lines · Eric Blake
Quoted 11 lines · Daniel P. Berrangé
Quoted 9 lines · Vladimir Sementsov-Ogievskiy

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)
---
  util/qemu-sockets.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 1 line

Thanks. Will queue through my NBD tree, since that's where the original problem was introduced.

Please add when queueing:

Fixes aec21d31756cbd
Signature · 2 lines
Best regards,
Vladimir
#4 lore raw
Quoted 15 lines · Vladimir Sementsov-Ogievskiy
Quoted 14 lines · Eric Blake
Quoted 12 lines · Daniel P. Berrangé
Quoted 9 lines · Vladimir Sementsov-Ogievskiy

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)

---
  util/qemu-sockets.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 8 lines
Quoted 3 lines

Thanks.  Will queue through my NBD tree, since that's where the original problem was introduced.

Please add when queueing:

Fixes aec21d31756cbd

Hmm, don't you forget? Don't see it neither in pull request nor in your branches.

Signature · 2 lines
Best regards,
Vladimir
#5 lore raw
Quoted 20 lines · Vladimir Sementsov-Ogievskiy
Quoted 19 lines · Vladimir Sementsov-Ogievskiy
Quoted 17 lines · Eric Blake
Quoted 4 lines · Daniel P. Berrangé
Quoted 3 lines · Vladimir Sementsov-Ogievskiy

In "if (saddr->keep_alive) {" we may already be on error path, with invalid sock < 0. Fix it by returning error earlier.

Quoted 8 lines
Quoted 6 lines
Reported-by Coverity (CID 1405300)

---
  util/qemu-sockets.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)

Thanks.  Will queue through my NBD tree, since that's where the original problem was introduced.

Quoted 6 lines
Quoted 4 lines

Please add when queueing:

Fixes aec21d31756cbd

Hmm, don't you forget? Don't see it neither in pull request nor in your branches.

Thanks for catching this. Fixing now...

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org