[Debian-ha-commits] [ocfs2-tools] 15/58: libocfs2: close fd if read fails in create_generation

Valentin Vidic vvidic-guest at moszumanska.debian.org
Tue Jun 20 13:40:41 UTC 2017


This is an automated email from the git hooks/post-receive script.

vvidic-guest pushed a commit to branch upstream
in repository ocfs2-tools.

commit 7f99736fb36ab1d57091e5bb447705f4424a0e5e
Author: Joseph Qi <joseph.qi at huawei.com>
Date:   Sat Jul 16 12:01:14 2016 +0800

    libocfs2: close fd if read fails in create_generation
    
    Currently fd is leaked if read fails in create_generation, so fix it.
    
    Signed-off-by: Joseph Qi <joseph.qi at huawei.com>
    Reviewed-by: Junxiao Bi <junxiao.bi at oracle.com>
---
 libocfs2/refcount.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libocfs2/refcount.c b/libocfs2/refcount.c
index 6afe032..bb23530 100644
--- a/libocfs2/refcount.c
+++ b/libocfs2/refcount.c
@@ -2138,8 +2138,10 @@ static errcode_t create_generation(uint32_t *value)
 	if (randfd < 0)
 		return errno;
 
-	if (read(randfd, value, readlen) != readlen)
+	if (read(randfd, value, readlen) != readlen) {
+		close(randfd);
 		return errno;
+	}
 
 	close(randfd);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-ha/ocfs2-tools.git



More information about the Debian-HA-Commits mailing list