|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3] libxc: check for various libxc failures and pass them down
...in xc_cpuid_{pv,hvm}_policy.
Coverity-ID: 1093050
Signed-off-by: Matthew Daley <mattjd@xxxxxxxxx>
---
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
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |