summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2018-08-21 15:07:16 -0700
committerAmar Tumballi <amarts@redhat.com>2018-08-23 03:45:24 +0000
commit33e7137a483a5abea8295b4d604edc6989241c12 (patch)
tree9463846786e9674157d3836b4987eb9a49275022 /xlators/features
parenta777df08ec8100a8d9067faf14b1058f09cf862a (diff)
features/changelog: Fix a file handle leak in htime_create()
In a few error scenarios, ht_file_hd was not being cleaned up. Addresses CID: 1325549 Change-Id: If9b4388aa700303c1eebbf1410dc35d18c4637df updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/changelog/src/changelog-helpers.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c
index 81bd99bcb7d..bfd2a29bdb1 100644
--- a/xlators/features/changelog/src/changelog-helpers.c
+++ b/xlators/features/changelog/src/changelog-helpers.c
@@ -817,6 +817,11 @@ htime_create (xlator_t *this,
goto out;
}
+ /* save this htime_fd in priv->htime_fd */
+ priv->htime_fd = ht_file_fd;
+
+ ht_file_fd = -1;
+
/* Set xattr HTIME_CURRENT on htime directory to htime filename */
ht_dir_fd = open (ht_dir_path, O_RDONLY);
if (ht_dir_fd == -1) {
@@ -847,14 +852,14 @@ htime_create (xlator_t *this,
goto out;
}
- /* save this htime_fd in priv->htime_fd */
- priv->htime_fd = ht_file_fd;
/* initialize rollover-number in priv to 1 */
priv->rollover_count = 1;
out:
if (ht_dir_fd != -1)
sys_close (ht_dir_fd);
+ if (ht_file_fd != -1)
+ sys_close (ht_file_fd);
return ret;
}