From b76eb750ff4e5a698428465d6b54684d49319e40 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 8 Dec 2017 14:00:16 +0100 Subject: [PATCH 21/21] sockets: avoid crash when cleaning up sockets for an invalid FD RH-Author: Daniel P. Berrange Message-id: <20171208140016.29707-1-berrange@redhat.com> Patchwork-id: 78275 O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH] sockets: avoid crash when cleaning up sockets for an invalid FD Bugzilla: 1506218 RH-Acked-by: Dr. David Alan Gilbert RH-Acked-by: Laurent Vivier RH-Acked-by: Markus Armbruster 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 Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrange (cherry picked from commit 2d7ad7c05e762d5b10a57eba9af1bb6b41700854) Signed-off-by: Miroslav Rezanina --- util/qemu-sockets.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 1358c81..bca6a06 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1190,6 +1190,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) { -- 1.8.3.1