xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Daley <mattjd@gmail.com>
To: xen-devel@lists.xen.org
Cc: Matthew Daley <mattjd@gmail.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v3] libxc: check for various libxc failures and pass them down
Date: Sun,  3 Nov 2013 11:57:58 +1300	[thread overview]
Message-ID: <1383433078-4899-1-git-send-email-mattjd@gmail.com> (raw)
In-Reply-To: <1383311550.672.64.camel@kazak.uk.xensource.com>

...in xc_cpuid_{pv,hvm}_policy.

Coverity-ID: 1093050
Signed-off-by: Matthew Daley <mattjd@gmail.com>
---
 tools/libxc/xc_cpuid_x86.c |   41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index bbbf9b8..92b9d3e 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -268,28 +268,35 @@ static void xc_cpuid_config_xsave(
     }
 }
 
-static void xc_cpuid_hvm_policy(
+static int xc_cpuid_hvm_policy(
     xc_interface *xch, domid_t domid,
     const unsigned int *input, unsigned int *regs)
 {
     DECLARE_DOMCTL;
+    int rc;
     char brand[13];
     unsigned long nestedhvm;
     unsigned long pae;
     int is_pae, is_nestedhvm;
     uint64_t xfeature_mask;
 
-    xc_get_hvm_param(xch, domid, HVM_PARAM_PAE_ENABLED, &pae);
+    rc = xc_get_hvm_param(xch, domid, HVM_PARAM_PAE_ENABLED, &pae);
+    if ( rc )
+        return rc;
     is_pae = !!pae;
 
     /* Detecting Xen's atitude towards XSAVE */
     memset(&domctl, 0, sizeof(domctl));
     domctl.cmd = XEN_DOMCTL_getvcpuextstate;
     domctl.domain = domid;
-    do_domctl(xch, &domctl);
+    rc = do_domctl(xch, &domctl);
+    if ( rc )
+        return rc;
     xfeature_mask = domctl.u.vcpuextstate.xfeature_mask;
 
-    xc_get_hvm_param(xch, domid, HVM_PARAM_NESTEDHVM, &nestedhvm);
+    rc = xc_get_hvm_param(xch, domid, HVM_PARAM_NESTEDHVM, &nestedhvm);
+    if ( rc )
+        return rc;
     is_nestedhvm = !!nestedhvm;
 
     switch ( input[0] )
@@ -429,13 +436,15 @@ static void xc_cpuid_hvm_policy(
     else
         intel_xc_cpuid_policy(xch, domid, input, regs, is_pae, is_nestedhvm);
 
+    return rc;
 }
 
-static void xc_cpuid_pv_policy(
+static int xc_cpuid_pv_policy(
     xc_interface *xch, domid_t domid,
     const unsigned int *input, unsigned int *regs)
 {
     DECLARE_DOMCTL;
+    int rc;
     unsigned int guest_width;
     int guest_64bit, xen_64bit = hypervisor_is_64bit(xch);
     char brand[13];
@@ -443,7 +452,9 @@ static void xc_cpuid_pv_policy(
 
     xc_cpuid_brand_get(brand);
 
-    xc_domain_get_guest_width(xch, domid, &guest_width);
+    rc = xc_domain_get_guest_width(xch, domid, &guest_width);
+    if ( rc != 0 )
+        return rc;
     guest_64bit = (guest_width == 8);
 
     /* Detecting Xen's atitude towards XSAVE */
@@ -547,23 +558,29 @@ static void xc_cpuid_pv_policy(
         regs[0] = regs[1] = regs[2] = regs[3] = 0;
         break;
     }
+
+    return rc;
 }
 
 static int xc_cpuid_policy(
     xc_interface *xch, domid_t domid,
     const unsigned int *input, unsigned int *regs)
 {
+    int                 rc = 0;
     xc_dominfo_t        info;
 
-    if ( xc_domain_getinfo(xch, domid, 1, &info) == 0 )
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if ( rc < 0 )
+        return rc;
+    if ( rc == 0 )
         return -EINVAL;
 
     if ( info.hvm )
-        xc_cpuid_hvm_policy(xch, domid, input, regs);
+        rc = xc_cpuid_hvm_policy(xch, domid, input, regs);
     else
-        xc_cpuid_pv_policy(xch, domid, input, regs);
+        rc = xc_cpuid_pv_policy(xch, domid, input, regs);
 
-    return 0;
+    return rc;
 }
 
 static int xc_cpuid_do_domctl(
@@ -632,7 +649,9 @@ int xc_cpuid_apply_policy(xc_interface *xch, domid_t domid)
     for ( ; ; )
     {
         cpuid(input, regs);
-        xc_cpuid_policy(xch, domid, input, regs);
+        rc = xc_cpuid_policy(xch, domid, input, regs);
+        if ( rc )
+            return rc;
 
         if ( regs[0] || regs[1] || regs[2] || regs[3] )
         {
-- 
1.7.10.4

  reply	other threads:[~2013-11-02 22:57 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-30  7:51 Fixes for various minor Coverity issues, volume 3 Matthew Daley
2013-10-30  7:51 ` [PATCH 01/29] libxc: check for xc_domain_get_guest_width failure and pass it down Matthew Daley
2013-10-31 21:03   ` Ian Campbell
2013-11-01  0:24     ` [PATCH v2] " Matthew Daley
2013-11-01 13:12       ` Ian Campbell
2013-11-02 22:57         ` Matthew Daley [this message]
2013-11-02 23:08           ` [PATCH v4] libxc: check for various libxc failures and pass them down Matthew Daley
2013-11-04 17:31             ` Ian Campbell
2013-11-05  4:58               ` Matthew Daley
2013-11-05 10:10                 ` Ian Campbell
2013-10-30  7:51 ` [PATCH 02/29] libxc: fix retrieval of and remove pointless check on gzip size Matthew Daley
2013-10-30 10:50   ` Andrew Cooper
2013-10-30 22:08     ` Matthew Daley
2013-10-31  2:58   ` [PATCH v2] " Matthew Daley
2013-10-31 10:22     ` Andrew Cooper
2013-10-31 22:07       ` Ian Campbell
2013-10-30  7:51 ` [PATCH 03/29] libxc: fix memory leak in move_l3_below_4G error handling Matthew Daley
2013-10-30  7:51 ` [PATCH 04/29] libxc: don't ignore fd read failures when restoring a domain Matthew Daley
2013-10-30  7:51 ` [PATCH 05/29] libxc: tidy up loop construct in write_compressed Matthew Daley
2013-10-30  7:51 ` [PATCH 06/29] libxc: don't read uninitialized size value in xc_read_image Matthew Daley
2013-10-31 21:22   ` Ian Campbell
2013-10-31 22:12     ` Matthew Daley
2013-10-31 22:26       ` Ian Campbell
2013-10-30  7:51 ` [PATCH 07/29] libxc: remove pointless null pointer check in xc_interface_open_common Matthew Daley
2013-10-30  7:51 ` [PATCH 08/29] libxc: check for xc_domain_get_guest_width failure in xc_domain_resume_any Matthew Daley
2013-10-30  7:51 ` [PATCH 09/29] libxc: check for xc_vcpu_setcontext " Matthew Daley
2013-10-31 21:56   ` Ian Campbell
2013-11-01  0:27     ` [PATCH v2] " Matthew Daley
2013-11-01 13:26       ` Ian Campbell
2013-11-01 16:34     ` [PATCH 09/29] " Ian Jackson
2013-11-04 10:29       ` Ian Campbell
2013-10-30  7:51 ` [PATCH 10/29] libxc: initalize stdio loggers' progress_last_percent values to 0 Matthew Daley
2013-10-30  7:51 ` [PATCH 11/29] libxc: remove null pointer checks in xc_pm_get_{c, p}xstat Matthew Daley
2013-10-30  7:51 ` [PATCH 12/29] libxl: check for transaction abortion failure in libxl_set_memory_target Matthew Daley
2013-10-30  7:51 ` [PATCH 13/29] libxl: check for xc_domain_max_vcpus failure in libxl__build_pre Matthew Daley
2013-10-31 21:29   ` Ian Campbell
2013-11-01  0:29     ` [PATCH v2] " Matthew Daley
2013-11-01 13:27       ` Ian Campbell
2013-10-30  7:51 ` [PATCH 14/29] libxl: don't leak xs_read results in libxl__device_nic_from_xs_be Matthew Daley
2013-10-30  8:58   ` Roger Pau Monné
2013-10-30  9:51     ` Matthew Daley
2013-10-31 21:31       ` Ian Campbell
2013-10-30  7:51 ` [PATCH 15/29] libxl: correct file open success check in libxl__device_pci_reset Matthew Daley
2013-10-30  7:51 ` [PATCH 16/29] libxl: check for xc_domain_shutdown failure in libxl__domain_suspend_common_callback Matthew Daley
2013-10-31 21:36   ` Ian Campbell
2013-11-01  0:30     ` [PATCH v2] " Matthew Daley
2013-11-01 13:27       ` Ian Campbell
2013-10-30  7:51 ` [PATCH 17/29] libxl: don't leak memory in libxl__poller_get failure case Matthew Daley
2013-10-30  7:51 ` [PATCH 18/29] libxl: only close fds which successfully opened in libxl__spawn_local_dm Matthew Daley
2013-10-30  7:51 ` [PATCH 19/29] xl: libxl_list_vm returns a pointer, not a handle Matthew Daley
2013-10-30  7:51 ` [PATCH 20/29] xl: check for restore file open failure in create_domain Matthew Daley
2013-10-30  7:51 ` [PATCH 21/29] xl: remove needless infinite-loop construct " Matthew Daley
2013-10-30  7:51 ` [PATCH 22/29] xl: correct references to long-removed function in error messages Matthew Daley
2013-10-30  7:51 ` [PATCH 23/29] docs: make `xl vcpu-list` example use verbatim formatting Matthew Daley
2013-10-30 10:53   ` Matthew Daley
2013-10-31  3:02   ` [PATCH v2] docs: make `xl vm-list` " Matthew Daley
2013-10-30  7:52 ` [PATCH 24/29] libvchan: handle libxc evtchn failures properly in init functions Matthew Daley
2013-10-30 10:12   ` Matthew Daley
2013-10-30 14:52     ` Daniel De Graaf
2013-10-30 22:07       ` Matthew Daley
2013-10-30 22:17         ` Matthew Daley
2013-10-31  3:41   ` [PATCH v2] " Matthew Daley
2013-10-30  7:52 ` [PATCH 25/29] libvchan: check for fcntl failures in select-type sample application Matthew Daley
2013-10-30 17:06   ` Daniel De Graaf
2013-10-30 17:13     ` Andrew Cooper
2013-10-30 22:04     ` Matthew Daley
2013-10-31  3:44   ` [PATCH v2] libvchan: tidy up usages of fcntl " Matthew Daley
2013-10-31 21:47     ` Ian Campbell
2013-11-01  0:33       ` [PATCH v3] " Matthew Daley
2013-11-01 13:28         ` Ian Campbell
2013-11-01 14:11           ` Daniel De Graaf
2013-11-04 17:51             ` Ian Campbell
2013-10-30  7:52 ` [PATCH 26/29] xenctx: only alloc symbol if we are inserting it into the symbol table Matthew Daley
2013-10-30  8:59   ` Jan Beulich
2013-10-30  7:52 ` [PATCH 27/29] xenctx: correct error check when opening libxc Matthew Daley
2013-10-30 12:48   ` George Dunlap
2013-10-30  7:52 ` [PATCH 28/29] xentrace: don't try to close null libxc handle in disable_tbufs Matthew Daley
2013-10-30 12:47   ` George Dunlap
2013-10-30  7:52 ` [PATCH 29/29] xentrace: undeadify invalid option argument handling Matthew Daley
2013-10-30 12:47   ` George Dunlap
2013-10-31 12:28 ` Fixes for various minor Coverity issues, volume 3 Andrew Cooper
2013-10-31 21:55   ` Matthew Daley
2013-10-31 22:10   ` Ian Campbell
2013-11-01  2:08     ` Matthew Daley

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=1383433078-4899-1-git-send-email-mattjd@gmail.com \
    --to=mattjd@gmail.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).