Skip to contentSkip to conversation

x86: fix error handling in MTRR code

PATCH New Jan Beulich 1 participant 1 message Oct 4, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: fix error handling in MTRR code

xen/arch/x86/platform_hypercall.c +12 -5
Index: 2006-09-21/xen/arch/x86/platform_hypercall.c
===================================================================
@@ -58,12 +58,17 @@ long do_platform_op(XEN_GUEST_HANDLE(xen
             op->u.add_memtype.nr_mfns,
             op->u.add_memtype.type,
             1);
-        if ( ret > 0 )
+        if ( ret >= 0 )
         {
             op->u.add_memtype.handle = 0;
             op->u.add_memtype.reg    = ret;
-            (void)copy_to_guest(u_xenpf_op, op, 1);
-            ret = 0;
+            if ( copy_to_guest(u_xenpf_op, op, 1) == 0 )
+                ret = 0;
+            else
+            {
+                mtrr_del_page(ret, 0, 0);
+                ret = -EFAULT;
+            }
         }
     }
     break;
@@ -96,8 +101,10 @@ long do_platform_op(XEN_GUEST_HANDLE(xen
             op->u.read_memtype.mfn     = mfn;
             op->u.read_memtype.nr_mfns = nr_mfns;
             op->u.read_memtype.type    = type;
-            (void)copy_to_guest(u_xenpf_op, op, 1);
-            ret = 0;
+            if ( copy_to_guest(u_xenpf_op, op, 1) == 0 )
+                ret = 0;
+            else
+                ret = -EFAULT;
         }
     }
     break;