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] fix few small memory leaks in libxc

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] fix few small memory leaks in libxc
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Wed, 21 Oct 2009 17:32:16 +0100
Delivery-date: Wed, 21 Oct 2009 09:32:20 -0700
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)
Hi all,
running qemu with valgrind I found I couple of small memory leaks in
libxc, this patch fixes them.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

---

diff -r 3bbe9ab2202b tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Wed Oct 21 09:23:10 2009 +0100
+++ b/tools/libxc/xc_linux.c    Wed Oct 21 17:27:39 2009 +0100
@@ -95,6 +95,7 @@
     xen_pfn_t *arr;
     int num;
     int i;
+    void *ret;
 
     num = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
     arr = calloc(num, sizeof(xen_pfn_t));
@@ -102,7 +103,9 @@
     for ( i = 0; i < num; i++ )
         arr[i] = mfn + i;
 
-    return xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
+    ret = xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
+    free(arr);
+    return ret;
 }
 
 void *xc_map_foreign_ranges(int xc_handle, uint32_t dom,
@@ -114,6 +117,7 @@
     int num;
     int i;
     int j;
+    void *ret;
 
     num_per_entry = chunksize >> PAGE_SHIFT;
     num = num_per_entry * nentries;
@@ -123,7 +127,9 @@
         for ( j = 0; j < num_per_entry; j++ )
             arr[i * num_per_entry + j] = entries[i].mfn + j;
 
-    return xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
+    ret = xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
+    free(arr);
+    return ret;
 }
 
 static int do_privcmd(int xc_handle, unsigned int cmd, unsigned long data)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] fix few small memory leaks in libxc, Stefano Stabellini <=