From 16aafe3974d53c5b8d85e9e6059853b8e3016a33 Mon Sep 17 00:00:00 2001 From: Lon Hohberger Date: Thu, 14 Jan 2010 18:46:21 -0500 Subject: [PATCH] Fix memory leaks found with valgrind Signed-off-by: Lon Hohberger --- server/libvirt.c | 2 ++ server/mcast.c | 2 ++ server/serial.c | 2 ++ server/static_map.c | 2 +- server/virt-serial.c | 2 +- server/virt-sockets.c | 3 +++ 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/server/libvirt.c b/server/libvirt.c index b03bd35..11cccb1 100644 --- a/server/libvirt.c +++ b/server/libvirt.c @@ -465,9 +465,11 @@ libvirt_shutdown(backend_context_t c) VALIDATE(info); if (virConnectClose(info->vp) < 0) { + free(info); return -errno; } + free(info); return 0; } diff --git a/server/mcast.c b/server/mcast.c index dd58357..636c485 100644 --- a/server/mcast.c +++ b/server/mcast.c @@ -569,6 +569,8 @@ mcast_shutdown(listener_context_t c) VALIDATE(info); info->magic = 0; + history_wipe(info->history); + free(info->history); free(info->args.key_file); free(info->args.addr); close(info->mc_sock); diff --git a/server/serial.c b/server/serial.c index fea9352..6668344 100644 --- a/server/serial.c +++ b/server/serial.c @@ -391,6 +391,8 @@ serial_shutdown(listener_context_t c) info->magic = 0; stop_event_listener(); domain_sock_cleanup(); + history_wipe(info->history); + free(info->history); free(info->uri); free(info->path); free(info); diff --git a/server/static_map.c b/server/static_map.c index 8f765a3..119770e 100644 --- a/server/static_map.c +++ b/server/static_map.c @@ -28,7 +28,7 @@ struct perm_group { static void static_map_cleanup(void **info) { - struct perm_group *groups = (struct perm_group *)info; + struct perm_group *groups = (struct perm_group *)(*info); struct perm_group *group; struct perm_entry *entry; diff --git a/server/virt-serial.c b/server/virt-serial.c index 8f5278c..065f846 100644 --- a/server/virt-serial.c +++ b/server/virt-serial.c @@ -562,7 +562,7 @@ int stop_event_listener(void) { run = 0; - pthread_cancel(event_tid); + //pthread_cancel(event_tid); pthread_join(event_tid, NULL); event_tid = 0; diff --git a/server/virt-sockets.c b/server/virt-sockets.c index 3b4b77b..b6ad110 100644 --- a/server/virt-sockets.c +++ b/server/virt-sockets.c @@ -46,6 +46,9 @@ domain_sock_setup(const char *domain, const char *socket_path) if (connect(sock, (struct sockaddr *)sun, SUN_LEN(sun)) < 0) goto out_fail; + free(sun); + sun = NULL; + node = malloc(sizeof(*node)); if (!node) goto out_fail;