Stefano Stabellini
2011-Feb-17 15:40 UTC
[Xen-devel] [PATCH] xl daemon: fix some memory leaks
xl daemon: fix some memory leaks If we are watching multiple disks we have to free multiple waiters. Free the event before continuing the loop. Destroy the disk device returned by libxl_event_get_disk_eject_info. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> diff -r 20b0f74bc31c tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Feb 17 12:25:09 2011 +0000 +++ b/tools/libxl/xl_cmdimpl.c Thu Feb 17 15:31:43 2011 +0000 @@ -1338,7 +1338,7 @@ static int create_domain(struct domain_c const char *restore_file = dom_info->restore_file; int migrate_fd = dom_info->migrate_fd; - int fd; + int fd, i; int need_daemon = 1; int ret, rc; libxl_waiter *w1 = NULL, *w2 = NULL; @@ -1607,7 +1607,10 @@ start: case LIBXL_EVENT_DOMAIN_DEATH: ret = libxl_event_get_domain_death_info(&ctx, domid, &event, &info); - if (ret < 0) continue; + if (ret < 0) { + libxl_free_event(&event); + continue; + } LOG("Domain %d is dead", domid); @@ -1623,7 +1626,8 @@ start: /* Otherwise fall through and restart. */ case 1: - libxl_free_waiter(w1); + for (i = 0; i < d_config.num_disks; i++) + libxl_free_waiter(&w1[i]); libxl_free_waiter(w2); free(w1); free(w2); @@ -1659,8 +1663,10 @@ start: } break; case LIBXL_EVENT_DISK_EJECT: - if (libxl_event_get_disk_eject_info(&ctx, domid, &event, &disk)) + if (libxl_event_get_disk_eject_info(&ctx, domid, &event, &disk)) { libxl_cdrom_insert(&ctx, domid, &disk); + libxl_device_disk_destroy(&disk); + } break; } libxl_free_event(&event); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Feb-17 19:12 UTC
Re: [Xen-devel] [PATCH] xl daemon: fix some memory leaks
Stefano Stabellini writes ("[Xen-devel] [PATCH] xl daemon: fix some memory leaks"):> xl daemon: fix some memory leaksApplied, thanks. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel