]> xenbits.xensource.com Git - xen.git/commitdiff
memory: exit early from memory_exchange() upon write-back error
authorJan Beulich <jbeulich@suse.com>
Wed, 3 May 2017 15:05:11 +0000 (17:05 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 3 May 2017 15:05:11 +0000 (17:05 +0200)
There's no point in continuing if in the end we'll return -EFAULT
anyway. It also seems wrong to report a chunk for which at least one
write-back failed as successfully exchanged (albeit the indication of
an error is also not fully correct, as the exchange happened in that
case at least partially - retrieving the GFN to assign the memory to
and/or handing back the information on the replacement memory didn't
work). In any case limiting the amount of damage done to the guest
can't be all that bad an idea.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 1cf4d2ec0d7c0cb53729ca810e416793030f6f07
master date: 2017-04-05 16:39:16 +0200

xen/common/memory.c

index 17f9e1ef35c294472acabbb34308a7af9541ee2a..dd11c272e3e7e0c3c15b036824a26189f325583d 100644 (file)
@@ -640,6 +640,9 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)
             }
         }
         BUG_ON( !(d->is_dying) && (j != (1UL << out_chunk_order)) );
+
+        if ( rc )
+            goto fail;
     }
 
     exch.nr_exchanged = exch.in.nr_extents;