[lvm-devel] master - dmsetup: check for NULL from dm_task_get_ioctl_timestamp

Zdenek Kabelac zkabelac at fedoraproject.org
Mon Nov 9 09:28:09 UTC 2015


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e90c5d206043af53e868c785707dabf070fa5747
Commit:        e90c5d206043af53e868c785707dabf070fa5747
Parent:        9df3069083cd49f75e0ec54fc1e699b057129934
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Sun Nov 8 19:27:22 2015 +0100
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Mon Nov 9 10:19:19 2015 +0100

dmsetup: check for NULL from dm_task_get_ioctl_timestamp

Coverity: ensure NULL is not passed to dm_timestamp_delta().
---
 tools/dmsetup.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 036f58c..a5cbef5 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -401,15 +401,18 @@ static int _task_run(struct dm_task *dmt)
 {
 	int r;
 	uint64_t delta;
+	struct dm_timestamp *ts;
 
 	if (_initial_timestamp)
 		dm_task_set_record_timestamp(dmt);
 
 	r = dm_task_run(dmt);
 
-	if (_initial_timestamp) {
-		delta = dm_timestamp_delta(dm_task_get_ioctl_timestamp(dmt), _initial_timestamp);
-		log_debug("Timestamp: %7" PRIu64 ".%09" PRIu64 " seconds", delta / NSEC_PER_SEC, delta % NSEC_PER_SEC);
+	if (_initial_timestamp &&
+	    (ts = dm_task_get_ioctl_timestamp(dmt))) {
+		delta = dm_timestamp_delta(ts, _initial_timestamp);
+		log_debug("Timestamp: %7" PRIu64 ".%09" PRIu64 " seconds",
+			  delta / NSEC_PER_SEC, delta % NSEC_PER_SEC);
 	}
 
 	return r;




More information about the lvm-devel mailing list