From: Olaf Hering <olaf@aepfle.de>
To: xen-devel@lists.xensource.com
Subject: [PATCH] tools/libxc: fix error handling in xc_mem_paging_load
Date: Wed, 18 Jan 2012 18:15:24 +0100 [thread overview]
Message-ID: <1821b0e1ce16d0015542.1326906924@probook.site> (raw)
# HG changeset patch
# User Olaf Hering <olaf@aepfle.de>
# Date 1326906775 -3600
# Node ID 1821b0e1ce16d0015542d4164505d97f130f09d7
# Parent 15ab61865ecbd146f6ce65fbea5bf49bfd9c6cb1
tools/libxc: fix error handling in xc_mem_paging_load
xc_mem_paging_load() does not pass errors in errno and the actual errno
from xc_mem_event_control() is overwritten by munlock().
xenpaging_populate_page() needs to check errno, but with the switch to
xc_mem_paging_load() it could not receive ENOMEM anymore.
Update xc_mem_paging_load() to return -1 and preserve errno during
munlock().
Signed-off-by: Olaf Hering <olaf@aepfle.de>
diff -r 15ab61865ecb -r 1821b0e1ce16 tools/libxc/xc_mem_paging.c
--- a/tools/libxc/xc_mem_paging.c
+++ b/tools/libxc/xc_mem_paging.c
@@ -68,23 +68,28 @@ int xc_mem_paging_prep(xc_interface *xch
int xc_mem_paging_load(xc_interface *xch, domid_t domain_id,
unsigned long gfn, void *buffer)
{
- int rc;
+ int rc, old_errno;
+
+ errno = -EINVAL;
if ( !buffer )
- return -EINVAL;
+ return -1;
if ( ((unsigned long) buffer) & (XC_PAGE_SIZE - 1) )
- return -EINVAL;
+ return -1;
if ( mlock(buffer, XC_PAGE_SIZE) )
- return -errno;
+ return -1;
rc = xc_mem_event_control(xch, domain_id,
XEN_DOMCTL_MEM_EVENT_OP_PAGING_PREP,
XEN_DOMCTL_MEM_EVENT_OP_PAGING,
buffer, NULL, gfn);
- (void)munlock(buffer, XC_PAGE_SIZE);
+ old_errno = errno;
+ munlock(buffer, XC_PAGE_SIZE);
+ errno = old_errno;
+
return rc;
}
next reply other threads:[~2012-01-18 17:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-18 17:15 Olaf Hering [this message]
[not found] <mailman.761.1326908012.1471.xen-devel@lists.xensource.com>
2012-01-18 18:23 ` [PATCH] tools/libxc: fix error handling in xc_mem_paging_load Andres Lagar-Cavilla
2012-01-26 10:54 ` Andres Lagar-Cavilla
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=1821b0e1ce16d0015542.1326906924@probook.site \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).