aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_linux.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-10-23 10:00:22 +0100
committerKeir Fraser <keir.fraser@citrix.com>2009-10-23 10:00:22 +0100
commit7de68b16110e63e9a19e6410cc8dab0abd95d5ec (patch)
tree86b2adb5634aabfb0a4ec7d468f491b8e8df3629 /tools/libxc/xc_linux.c
parentbee72b5893bfbffed54a1b3db46a99f4cb95f040 (diff)
downloadxen-7de68b16110e63e9a19e6410cc8dab0abd95d5ec.tar.gz
xen-7de68b16110e63e9a19e6410cc8dab0abd95d5ec.tar.bz2
xen-7de68b16110e63e9a19e6410cc8dab0abd95d5ec.zip
libxc: fix a few memory leaks
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@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_linux.c')
-rw-r--r--tools/libxc/xc_linux.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/libxc/xc_linux.c b/tools/libxc/xc_linux.c
index b79a57fe2a..fb8c61c573 100644
--- a/tools/libxc/xc_linux.c
+++ b/tools/libxc/xc_linux.c
@@ -95,6 +95,7 @@ void *xc_map_foreign_range(int xc_handle, uint32_t dom,
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 @@ void *xc_map_foreign_range(int xc_handle, uint32_t dom,
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 @@ void *xc_map_foreign_ranges(int xc_handle, uint32_t dom,
int num;
int i;
int j;
+ void *ret;
num_per_entry = chunksize >> PAGE_SHIFT;
num = num_per_entry * nentries;
@@ -123,7 +127,9 @@ void *xc_map_foreign_ranges(int xc_handle, uint32_t dom,
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)