WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xl daemon: fix some memory leaks

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xl daemon: fix some memory leaks
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Thu, 17 Feb 2011 15:40:50 +0000
Delivery-date: Thu, 17 Feb 2011 07:41:44 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
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@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>