All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Wei Liu <wei.liu2@citrix.com>, Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [PATCH v2 1/3] libxl: use libxl__read_xenstore_mandatory in vtpm function
Date: Mon, 18 Sep 2017 14:56:12 +0100	[thread overview]
Message-ID: <20170918135614.30868-2-wei.liu2@citrix.com> (raw)
In-Reply-To: <20170918135614.30868-1-wei.liu2@citrix.com>

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>
---
 tools/libxl/libxl_vtpm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c
index 21320870d4..6182cfc49c 100644
--- a/tools/libxl/libxl_vtpm.c
+++ b/tools/libxl/libxl_vtpm.c
@@ -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;
-- 
2.11.0


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

  reply	other threads:[~2017-09-18 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 13:56 [PATCH v2 0/3] Some coverity fixes for xl/libxl Wei Liu
2017-09-18 13:56 ` Wei Liu [this message]
2017-09-18 13:56 ` [PATCH v2 2/3] libxl: use libxl__read_xenstore_mandatory in vdispl function Wei Liu
2017-09-18 13:56 ` [PATCH v2 3/3] xl: avoid leaking memory in vdispl parser Wei Liu
2017-09-18 15:38 ` [PATCH v2 0/3] Some coverity fixes for xl/libxl Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170918135614.30868-2-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.