The error path in get_huge_pages after calling hugetlbfs_prefault calls munmap() and close() before trying to use the errno set in hugetlbfs_prefault. This patch saves errno before making these calls and then used the saved value in the output.
Signed-off-by: Eric B Munson <[email protected]> --- alloc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/alloc.c b/alloc.c index e9ae969..60a525e 100644 --- a/alloc.c +++ b/alloc.c @@ -78,6 +78,7 @@ void *get_huge_pages(size_t len, ghp_t flags) { void *buf; int buf_fd; + int saved_error; /* Catch an altogether-too easy typo */ if (flags & GHR_MASK) @@ -104,11 +105,12 @@ void *get_huge_pages(size_t len, ghp_t flags) /* Fault the region to ensure accesses succeed */ if (hugetlbfs_prefault(buf_fd, buf, len) != 0) { + saved_error = errno; munmap(buf, len); close(buf_fd); WARNING("get_huge_pages: Prefaulting failed (flags: 0x%lX): %s\n", - flags, strerror(errno)); + flags, strerror(saved_error)); return NULL; } -- 1.6.3.3 ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Libhugetlbfs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel
