]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: use libxl__read_xenstore_mandatory in vtpm function
authorWei Liu <wei.liu2@citrix.com>
Mon, 18 Sep 2017 13:56:12 +0000 (14:56 +0100)
committerWei Liu <wei.liu2@citrix.com>
Mon, 18 Sep 2017 15:41:09 +0000 (16:41 +0100)
libxl__read_xenstore can return NULL. Use the _mandatory variant to
return early when the read fails.

Coverity-ID: 1418098

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_vtpm.c

index 21320870d4f17c646cb7b8bda16d35dcda2f518a..6182cfc49c8a4c3bb7729ac7cdfa2a28f863f282 100644 (file)
@@ -79,12 +79,15 @@ static int libxl__vtpm_from_xenstore(libxl__gc *gc, const char *libxl_path,
                                      libxl_device_vtpm *vtpm)
 {
     int rc;
-    char *be_path;
+    const char *be_path;
     char *uuid;
 
     vtpm->devid = devid;
 
-    be_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/backend", libxl_path));
+    rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+                                  GCSPRINTF("%s/backend", libxl_path),
+                                  &be_path);
+    if (rc) return rc;
 
     rc = libxl__backendpath_parse_domid(gc, be_path, &vtpm->backend_domid);
     if (rc) return rc;