[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 6 of 7] xl: Fix invalid return of libxl-internal pointers via libxl_poolid_to_name()
tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_utils.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) This function has in-and-out-of-library callers. In library callers now use _libxl_poolid_to_name() which participates in garbage collection and out-of-library callers are fixed up to free() the domain name. Signed-off-by: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx> diff -r b4d2cf5a2a60 -r 4c643fd7aaa2 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Tue Aug 10 15:50:03 2010 +0100 +++ b/tools/libxl/libxl_internal.h Tue Aug 10 15:50:42 2010 +0100 @@ -227,6 +227,7 @@ char *libxl_abs_path(libxl_ctx *ctx, cha #define XL_LOG_ERROR XTL_ERROR char *_libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid); +char *_libxl_poolid_to_name(libxl_ctx *ctx, uint32_t poolid); #endif diff -r b4d2cf5a2a60 -r 4c643fd7aaa2 tools/libxl/libxl_utils.c --- a/tools/libxl/libxl_utils.c Tue Aug 10 15:50:03 2010 +0100 +++ b/tools/libxl/libxl_utils.c Tue Aug 10 15:50:42 2010 +0100 @@ -98,7 +98,14 @@ char *libxl_poolid_to_name(libxl_ctx *ct return "Pool-0"; snprintf(path, sizeof(path), "/local/pool/%d/name", poolid); s = xs_read(ctx->xsh, XBT_NULL, path, &len); - libxl_ptr_add(ctx, s); + return s; +} + +char *_libxl_poolid_to_name(libxl_ctx *ctx, uint32_t poolid) +{ + char *s = libxl_poolid_to_name(ctx, poolid); + if ( s ) + libxl_ptr_add(ctx, s); return s; } @@ -114,7 +121,7 @@ int libxl_name_to_poolid(libxl_ctx *ctx, return ERROR_NOMEM; for (i = 0; i < nb_pools; i++) { - poolname = libxl_poolid_to_name(ctx, poolinfo[i].poolid); + poolname = _libxl_poolid_to_name(ctx, poolinfo[i].poolid); if (!poolname) continue; if (strcmp(poolname, name) == 0) { _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |