[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] xl: Fix invalid return of internal ptrs via libxl_poolid_to_name
# HG changeset patch # User "Gianni Tedesco (3P)" <gianni.tedesco@xxxxxxxxxx> # Date 1281528543 -3600 # Node ID 814eb6baf9799e3e72ac509cfb735357cf96595f # Parent 8c60cc6aabd473e851c478e897184dc16e3f49c2 xl: Fix invalid return of internal ptrs via libxl_poolid_to_name libxl_poolid_to_name 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> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_utils.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff -r 8c60cc6aabd4 -r 814eb6baf979 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Wed Aug 11 13:08:14 2010 +0100 +++ b/tools/libxl/libxl_internal.h Wed Aug 11 13:09:03 2010 +0100 @@ -228,6 +228,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 8c60cc6aabd4 -r 814eb6baf979 tools/libxl/libxl_utils.c --- a/tools/libxl/libxl_utils.c Wed Aug 11 13:08:14 2010 +0100 +++ b/tools/libxl/libxl_utils.c Wed Aug 11 13:09:03 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; } @@ -115,7 +122,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-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |