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

[Xen-devel] [PATCH v2] libxc: check for xc_domain_get_guest_width failure and pass it down



...in xc_cpuid_pv_policy.

Coverity-ID: 1093050
Signed-off-by: Matthew Daley <mattjd@xxxxxxxxx>
---
v2: Return actual error from xc_domain_get_guest_width

 tools/libxc/xc_cpuid_x86.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index bbbf9b8..328769a 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -431,11 +431,12 @@ static void xc_cpuid_hvm_policy(
 
 }
 
-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 +444,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,6 +550,8 @@ static void xc_cpuid_pv_policy(
         regs[0] = regs[1] = regs[2] = regs[3] = 0;
         break;
     }
+
+    return rc;
 }
 
 static int xc_cpuid_policy(
@@ -561,7 +566,8 @@ static int xc_cpuid_policy(
     if ( info.hvm )
         xc_cpuid_hvm_policy(xch, domid, input, regs);
     else
-        xc_cpuid_pv_policy(xch, domid, input, regs);
+        if ( xc_cpuid_pv_policy(xch, domid, input, regs) != 0 )
+            return -EINVAL;
 
     return 0;
 }
@@ -632,7 +638,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


 


Rackspace

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