[lvm-devel] master - dmsetup: fix timestamp leak
Bryn Reeves
bmr at fedoraproject.org
Mon Jul 4 11:17:18 UTC 2016
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=52be93c54bfedf16bb86472c03b6833d2be0efd1
Commit: 52be93c54bfedf16bb86472c03b6833d2be0efd1
Parent: 62dce13c7a00a71c73926340e05053b7ebee48e9
Author: Bryn M. Reeves <bmr at redhat.com>
AuthorDate: Wed Jun 29 10:14:57 2016 +0100
Committer: Bryn M. Reeves <bmr at redhat.com>
CommitterDate: Mon Jul 4 12:16:51 2016 +0100
dmsetup: fix timestamp leak
With a single report (--count=1) no timerfd is set up and the cycle
and current timestamps should be freed during the single call to
_update_interval_times().
---
tools/dmsetup.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 03e2519..8ba12dd 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -703,13 +703,16 @@ static int _update_interval_times(void)
{
static struct dm_timestamp *this_timestamp = NULL;
uint64_t delta_t, interval_num = _interval_num();
- int r = 0;
+ int r = 1;
/*
* Clock shutdown for exit - nothing to do.
*/
- if (_timer_fd == TIMER_STOPPED && !_cycle_timestamp)
- return 1;
+ if ((_timer_fd == TIMER_STOPPED) && !_cycle_timestamp)
+ goto out;
+
+ /* clock is running */
+ r = 0;
/*
* Current timestamp. If _new_interval is set this is used as
@@ -780,7 +783,8 @@ static int _update_interval_times(void)
r = 1;
out:
- if (!r || _timer_fd == TIMER_STOPPED) {
+ /* timer stopped or never started */
+ if (!r || _timer_fd < 0) {
/* The _cycle_timestamp has not yet been allocated if we
* fail to obtain this_timestamp on the first interval.
*/
More information about the lvm-devel
mailing list