xl: Do not leak events when a domain exits.
authorIan Campbell <ian.campbell@citrix.com>
Fri, 26 Oct 2012 11:03:12 +0000 (12:03 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 26 Oct 2012 11:03:12 +0000 (12:03 +0100)
The goto in both of these places misses the event free which would
normally clean up.

==8655== 80 bytes in 1 blocks are definitely lost in loss record 1 of 1
==8655==    at 0x4024370: calloc (vg_replace_malloc.c:593)
==8655==    by 0x406EAAE: libxl__zalloc (libxl_internal.c:83)
==8655==    by 0x4078173: libxl__event_new (libxl_event.c:1167)
==8655==    by 0x4056373: domain_death_occurred (libxl.c:958)
==8655==    by 0x4058D06: domain_death_xswatch_callback (libxl.c:1038)
==8655==    by 0x4078EB5: watchfd_callback (libxl_event.c:458)
==8655==    by 0x407839E: afterpoll_internal (libxl_event.c:949)
==8655==    by 0x4079142: eventloop_iteration (libxl_event.c:1371)
==8655==    by 0x40799BB: libxl_event_wait (libxl_event.c:1396)
==8655==    by 0x805CC67: create_domain (xl_cmdimpl.c:1698)
==8655==    by 0x805E001: main_create (xl_cmdimpl.c:3986)
==8655==    by 0x804D43D: main (xl.c:285)

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c

index 5a947da40971c58787d74b32cec0a16a9750de58..a43b3712f60b554d048fe597d893432627de1176 100644 (file)
@@ -2118,6 +2118,7 @@ start:
 
             case 0:
                 LOG("Done. Exiting now");
+                libxl_event_free(ctx, event);
                 ret = 0;
                 goto out;
 
@@ -2127,6 +2128,7 @@ start:
 
         case LIBXL_EVENT_TYPE_DOMAIN_DEATH:
             LOG("Domain %d has been destroyed.", domid);
+            libxl_event_free(ctx, event);
             ret = 0;
             goto out;