diff mbox

[PULL,(for,2.11),v1,1/1] sockets: avoid crash when cleaning up sockets for an invalid FD

Message ID 20171128112301.5636-2-berrange@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel P. Berrangé Nov. 28, 2017, 11:23 a.m. UTC
If socket_listen_cleanup is passed an invalid FD, then querying the socket
local address will fail. We must thus be prepared for the returned addr to
be NULL

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 util/qemu-sockets.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 8b75541ce4..a1cf47e625 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -1079,6 +1079,9 @@  void socket_listen_cleanup(int fd, Error **errp)
     SocketAddress *addr;
 
     addr = socket_local_address(fd, errp);
+    if (!addr) {
+        return;
+    }
 
     if (addr->type == SOCKET_ADDRESS_TYPE_UNIX
         && addr->u.q_unix.path) {