# HG changeset 15389 patch
# User kfraser@localhost.localdomain
# Date 1182343102 -3600
# Node ID 07be0266f6d88f2a8343b54f36301f3adac88d18
# Parent  50358c4b37f4fcaac1061f1c84a865932401c1be
32-on-64: Fix error path from memory_op() hypercall.
Signed-off-by: Keir Fraser <keir@xensource.com>

Index: 2007-05-14/xen/common/compat/memory.c
===================================================================
--- 2007-05-14.orig/xen/common/compat/memory.c	2007-04-23 10:01:43.000000000 +0200
+++ 2007-05-14/xen/common/compat/memory.c	2007-07-02 10:48:06.000000000 +0200
@@ -258,7 +258,8 @@ int compat_memory_op(unsigned int cmd, X
                     compat_pfn_t pfn = nat.rsrv->extent_start.p[start_extent];
 
                     BUG_ON(pfn != nat.rsrv->extent_start.p[start_extent]);
-                    if ( __copy_to_compat_offset(cmp.rsrv.extent_start, start_extent, &pfn, 1) )
+                    if ( __copy_to_compat_offset(cmp.rsrv.extent_start,
+                                                 start_extent, &pfn, 1) )
                     {
                         if ( split >= 0 )
                         {
@@ -275,6 +276,10 @@ int compat_memory_op(unsigned int cmd, X
                         break;
                     }
                 }
+
+                /* Bail if there was an error. */
+                if ( (split >= 0) && (end_extent != nat.rsrv->nr_extents) )
+                    split = 0;
             }
             else
                 start_extent = end_extent;