@@ -652,19 +652,18 @@ static int page_make_sharable(struct domain *d,
return -EBUSY;
}
- /* Change page type and count atomically */
- if ( !get_page_and_type(page, d, PGT_shared_page) )
+ /* Check if page is already typed and bail early if it is */
+ if ( (page->u.inuse.type_info & PGT_count_mask) != 1 )
{
spin_unlock(&d->page_alloc_lock);
- return -EINVAL;
+ return -EEXIST;
}
- /* Check it wasn't already sharable and undo if it was */
- if ( (page->u.inuse.type_info & PGT_count_mask) != 1 )
+ /* Change page type and count atomically */
+ if ( !get_page_and_type(page, d, PGT_shared_page) )
{
spin_unlock(&d->page_alloc_lock);
- put_page_and_type(page);
- return -EEXIST;
+ return -EINVAL;
}
/*
Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com> --- xen/arch/x86/mm/mem_sharing.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)