[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v4 2/2] libxl: properly initialize device structures



This avoids returning unallocated memory in the libxl_device_vtpm
structure in libxl_device_vtpm_list, and uses libxl_device_nic_init
instead of memset when initializing libxl_device_nics.

Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
---

Changes from v3:
 - Also fix some memset => libxl_device_*_init calls

 tools/libxl/libxl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index b994fea..f0d7d2f 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1847,6 +1847,8 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, 
uint32_t domid, int *n
                 GCSPRINTF("%s/%s/backend",
                    fe_path, *dir));
 
+          libxl_device_vtpm_init(vtpm);
+
           vtpm->devid = atoi(*dir);
 
           tmp = libxl__xs_read(gc, XBT_NULL,
@@ -1950,7 +1952,7 @@ int libxl_devid_to_device_vtpm(libxl_ctx *ctx,
     if (!vtpms)
         return ERROR_FAIL;
 
-    memset(vtpm, 0, sizeof (libxl_device_vtpm));
+    libxl_device_vtpm_init(vtpm);
     rc = 1;
     for (i = 0; i < nb; ++i) {
         if(devid == vtpms[i].devid) {
@@ -2927,7 +2929,7 @@ static void libxl__device_nic_from_xs_be(libxl__gc *gc,
     char *tmp;
     int rc;
 
-    memset(nic, 0, sizeof(*nic));
+    libxl_device_nic_init(nic);
 
     tmp = xs_read(ctx->xsh, XBT_NULL,
                   libxl__sprintf(gc, "%s/handle", be_path), &len);
@@ -2966,7 +2968,7 @@ int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t 
domid,
     char *dompath, *path;
     int rc = ERROR_FAIL;
 
-    memset(nic, 0, sizeof (libxl_device_nic));
+    libxl_device_nic_init(nic);
     dompath = libxl__xs_get_dompath(gc, domid);
     if (!dompath)
         goto out;
-- 
1.8.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.