From: Olaf Hering <olaf@aepfle.de>
To: xen-devel@lists.xensource.com
Subject: [PATCH] do_memory_op: cleanup if copy_to_guest fails
Date: Thu, 16 Dec 2010 18:59:10 +0100 [thread overview]
Message-ID: <20101216175910.GA24006@aepfle.de> (raw)
Undo the page allocation in the ulikely event the copy_to_guest fails.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
I have not exercised this code path, it was found during code inspection in 4.0
xen/common/memory.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- xen-unstable.hg-4.1.22548.orig/xen/common/memory.c
+++ xen-unstable.hg-4.1.22548/xen/common/memory.c
@@ -82,7 +82,10 @@ static void increase_reservation(struct
{
mfn = page_to_mfn(page);
if ( unlikely(__copy_to_guest_offset(a->extent_list, i, &mfn, 1)) )
+ {
+ free_domheap_pages(page, a->extent_order);
goto out;
+ }
}
}
@@ -144,7 +147,13 @@ static void populate_physmap(struct memo
/* Inform the domain of the new page's machine address. */
if ( unlikely(__copy_to_guest_offset(a->extent_list, i, &mfn, 1)) )
+ {
+ for ( j = 0; j < (1 << a->extent_order); j++ )
+ set_gpfn_from_mfn(mfn + j, INVALID_M2P_ENTRY);
+ guest_physmap_remove_page(d, gpfn, mfn, a->extent_order);
+ free_domheap_pages(page, a->extent_order);
goto out;
+ }
}
}
}
next reply other threads:[~2010-12-16 17:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-16 17:59 Olaf Hering [this message]
2010-12-16 18:32 ` [PATCH] do_memory_op: cleanup if copy_to_guest fails Keir Fraser
2010-12-16 19:18 ` Olaf Hering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101216175910.GA24006@aepfle.de \
--to=olaf@aepfle.de \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.