aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_utils.c
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2012-09-14 10:02:50 +0100
committerIan Campbell <ian.campbell@citrix.com>2012-09-14 10:02:50 +0100
commit10a194b1c57de7ddc9d4fce07e01f2cd7d0ca26a (patch)
treef534d44504976bef99a331cbfe712ffa36198c4b /tools/libxl/libxl_utils.c
parent3c73d5f9473dfa897201dc03dc719bd1ccf8b77b (diff)
downloadxen-10a194b1c57de7ddc9d4fce07e01f2cd7d0ca26a.tar.gz
xen-10a194b1c57de7ddc9d4fce07e01f2cd7d0ca26a.tar.bz2
xen-10a194b1c57de7ddc9d4fce07e01f2cd7d0ca26a.zip
xl: do not leak cpupool names.
Valgrind reports: ==3076== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==3076== at 0x402458C: malloc (vg_replace_malloc.c:270) ==3076== by 0x406F86D: libxl_cpupoolid_to_name (libxl_utils.c:102) ==3076== by 0x8058742: parse_config_data (xl_cmdimpl.c:639) ==3076== by 0x805BD56: create_domain (xl_cmdimpl.c:1838) ==3076== by 0x805DAED: main_create (xl_cmdimpl.c:3903) ==3076== by 0x804D39D: main (xl.c:285) And indeed there are several places where xl uses libxl_cpupoolid_to_name as a boolean to test if the pool name is valid and leaks the name if it is. Introduce an is_valid helper and use that instead. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Juergen Gross<juergen.gross@ts.fujitsu.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_utils.c')
-rw-r--r--tools/libxl/libxl_utils.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index f7b44a0ee4..55cd29981b 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -103,6 +103,17 @@ char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid)
return s;
}
+/* This is a bit horrid but without xs_exists it seems like the only way. */
+int libxl_cpupoolid_is_valid(libxl_ctx *ctx, uint32_t poolid)
+{
+ int ret;
+ char *s = libxl_cpupoolid_to_name(ctx, poolid);
+
+ ret = (s != NULL);
+ free(s);
+ return ret;
+}
+
char *libxl__cpupoolid_to_name(libxl__gc *gc, uint32_t poolid)
{
char *s = libxl_cpupoolid_to_name(libxl__gc_owner(gc), poolid);