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 6 of 7] xl: Fix invalid return of libxl-internal poin

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 6 of 7] xl: Fix invalid return of libxl-internal pointers via libxl_poolid_to_name()
From: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Date: Tue, 10 Aug 2010 15:59:46 +0100
Cc: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>, Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Tue, 10 Aug 2010 08:09:12 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1281452380@xxxxxxxxxxxxxxxxxxxxxx>
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>
References: <patchbomb.1281452380@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
 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