[fedfs-utils] [PATCH 04/17] libjunction: Fix file descriptor leak in junction_get_mode()
Chuck Lever
chuck.lever at oracle.com
Sun May 11 14:28:39 PDT 2014
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 at oracle.com>
---
src/libjunction/junction.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libjunction/junction.c b/src/libjunction/junction.c
index 9d9a266..7b7b2e4 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",
More information about the fedfs-utils-devel
mailing list