If obtain_prepared_file fails for any reason, the last fd in our hugetlb segment table will be 0 when the error clean up starts because obtain_prepared_file does not write to the segment structure in error cases. Because the cleanup for loop starts at the segment where obtain_prepared_file failed it will try to close stdout (fd 0). This patch makes the cleanup for loop decrement the index before starting to close file descriptors.
Reported-by: Dan Scales <sca...@vmware.com> Signed-off-by: Eric B Munson <emun...@mgebm.net> --- elflink.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/elflink.c b/elflink.c index c24bedc..e92d2dd 100644 --- a/elflink.c +++ b/elflink.c @@ -1321,7 +1321,7 @@ void hugetlbfs_setup_elflink(void) "%d\n", i); /* Close files we have already prepared */ - for (; i >= 0; i--) + for (i--; i >= 0; i--) close(htlb_seg_table[i].fd); return; -- 1.7.5.4 ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel