From: Jan Beulich Date: Wed, 5 Apr 2017 14:39:16 +0000 (+0200) Subject: memory: exit early from memory_exchange() upon write-back error X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1cf4d2ec0d7c0cb53729ca810e416793030f6f07;p=people%2Froyger%2Fxen.git memory: exit early from memory_exchange() upon write-back error 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 Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Released-acked-by: Julien Grall --- diff --git a/xen/common/memory.c b/xen/common/memory.c index 7dbddda0e1..bed43e236d 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -639,6 +639,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;