aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric B Munson <emunson@mgebm.net>2010-12-15 10:59:41 -0700
committerEric B Munson <emunson@mgebm.net>2010-12-16 10:21:21 -0700
commit79f6f14defec00d4e4b1d00678715266928be402 (patch)
tree9e534d8bb9bc1c3c66f77f6461b65b7df970fa81
parenta72bf01c8cd68c691ec1c62f11a3e252d61e4be8 (diff)
downloadlibhugetlbfs-79f6f14defec00d4e4b1d00678715266928be402.tar.gz
Fix error value handling in get_huge_pages
hugetlbfs_prefault returns an error value instead of setting errno so we need to us the value returned for strerror instead of errno. Signed-off-by: Eric B Munson <emunson@mgebm.net>
-rw-r--r--alloc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/alloc.c b/alloc.c
index f5815a8..bce9464 100644
--- a/alloc.c
+++ b/alloc.c
@@ -78,9 +78,9 @@ void *get_huge_pages(size_t len, ghp_t flags)
{
void *buf;
int buf_fd = -1;
- int saved_error;
int mmap_reserve = __hugetlb_opts.no_reserve ? MAP_NORESERVE : 0;
int mmap_hugetlb = 0;
+ int ret;
/* Catch an altogether-too easy typo */
if (flags & GHR_MASK)
@@ -120,14 +120,14 @@ void *get_huge_pages(size_t len, ghp_t flags)
}
/* Fault the region to ensure accesses succeed */
- if (hugetlbfs_prefault(buf, len) != 0) {
- saved_error = errno;
+ ret = hugetlbfs_prefault(buf, len);
+ if (ret != 0) {
munmap(buf, len);
if (buf_fd >= 0)
close(buf_fd);
WARNING("get_huge_pages: Prefaulting failed (flags: 0x%lX): %s\n",
- flags, strerror(saved_error));
+ flags, strerror(ret));
return NULL;
}