ocfs2-tools/0001-libo2dlm-Close-file-description-after-use.patch

35 lines
984 B
Diff
Raw Normal View History

From 63a8fc605fc8dc1c4e327eb17ba6a5a614928608 Mon Sep 17 00:00:00 2001
From: piaojun <piaojun@huawei.com>
Date: Thu, 2 Apr 2015 20:46:47 +0800
Subject: [PATCH 1/2] libo2dlm: Close file description after use
In o2dlm_generate_random_value(), randfd should be closed after use.
Signed-off-by: Jun Piao <piaojun@huawei.com>
Reviewed-by: Alex Chen <alex.chen@huawei.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
libo2dlm/o2dlm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libo2dlm/o2dlm.c b/libo2dlm/o2dlm.c
index dbc642b..375f659 100644
--- a/libo2dlm/o2dlm.c
+++ b/libo2dlm/o2dlm.c
@@ -102,9 +102,10 @@ static errcode_t o2dlm_generate_random_value(int64_t *value)
if ((randfd = open("/dev/urandom", O_RDONLY)) == -1)
return O2DLM_ET_RANDOM;
- if (read(randfd, value, readlen) != readlen)
+ if (read(randfd, value, readlen) != readlen) {
+ close(randfd);
return O2DLM_ET_RANDOM;
-
+ }
close(randfd);
return 0;
--
2.1.2