diff mbox

[07/17] libjunction: Fix file descriptor leak in junction_get_mode()

Message ID 20140527153722.1177.14664.stgit@seurat.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever May 27, 2014, 3:37 p.m. UTC
A second close(2) is used to preserve the value of errno when
reporting the error via xlog().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 src/libjunction/junction.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/src/libjunction/junction.c b/src/libjunction/junction.c
index 9d9a26687fc3..7b7b2e4b4b12 100644
--- a/src/libjunction/junction.c
+++ b/src/libjunction/junction.c
@@ -394,9 +394,9 @@  junction_get_mode(const char *pathname, mode_t *mode)
 	if (fstat(fd, &stb) == -1) {
 		xlog(D_GENERAL, "%s: failed to stat %s: %m",
 			__func__, pathname);
+		(void)close(fd);
 		return FEDFS_ERR_ACCESS;
 	}
-
 	(void)close(fd);
 
 	xlog(D_CALL, "%s: pathname %s has mode %o",