[Ocfs2-tools-devel] [PATCH] libocfs2: close fd if read fails in create_generation
Joseph Qi
joseph.qi at huawei.com
Fri Jul 15 21:01:14 PDT 2016
Currently fd is leaked if read fails in create_generation, so fix it.
Signed-off-by: Joseph Qi <joseph.qi at huawei.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);
--
1.8.4.3
More information about the Ocfs2-tools-devel
mailing list