From 33e7137a483a5abea8295b4d604edc6989241c12 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Tue, 21 Aug 2018 15:07:16 -0700 Subject: 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 --- xlators/features/changelog/src/changelog-helpers.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'xlators/features') 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; } -- cgit