Blame SOURCES/0031-libmultipath-handle-clock_gettime-failures-in-tur-ch.patch

a1c519
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
a1c519
From: Benjamin Marzinski <bmarzins@redhat.com>
a1c519
Date: Thu, 16 May 2019 12:41:33 -0500
a1c519
Subject: [PATCH] libmultipath: handle clock_gettime failures in tur checker
a1c519
a1c519
If clock_gettime() fails, and multipathd can't figure out when it should
a1c519
time out, it should just default to assuming that it has already timed
a1c519
out. Found by coverity.
a1c519
a1c519
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
a1c519
---
a1c519
 libmultipath/checkers/tur.c | 19 +++++++++++++++----
a1c519
 1 file changed, 15 insertions(+), 4 deletions(-)
a1c519
a1c519
diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c
a1c519
index 6b08dbb..717353e 100644
a1c519
--- a/libmultipath/checkers/tur.c
a1c519
+++ b/libmultipath/checkers/tur.c
a1c519
@@ -290,7 +290,12 @@ static void *tur_thread(void *ctx)
a1c519
 
a1c519
 static void tur_timeout(struct timespec *tsp)
a1c519
 {
a1c519
-	clock_gettime(CLOCK_MONOTONIC, tsp);
a1c519
+	if (clock_gettime(CLOCK_MONOTONIC, tsp) != 0) {
a1c519
+		/* can't get time. clear tsp to not wait */
a1c519
+		tsp->tv_sec = 0;
a1c519
+		tsp->tv_nsec = 0;
a1c519
+		return;
a1c519
+	}
a1c519
 	tsp->tv_nsec += 1000 * 1000; /* 1 millisecond */
a1c519
 	normalize_timespec(tsp);
a1c519
 }
a1c519
@@ -300,8 +305,12 @@ static void tur_set_async_timeout(struct checker *c)
a1c519
 	struct tur_checker_context *ct = c->context;
a1c519
 	struct timespec now;
a1c519
 
a1c519
-	clock_gettime(CLOCK_MONOTONIC, &now;;
a1c519
-	ct->time = now.tv_sec + c->timeout;
a1c519
+	if (clock_gettime(CLOCK_MONOTONIC, &now) != 0)
a1c519
+		/* can't get time. clear time to always timeout on
a1c519
+		 * next path check */
a1c519
+		ct->time = 0;
a1c519
+	else
a1c519
+		ct->time = now.tv_sec + c->timeout;
a1c519
 }
a1c519
 
a1c519
 static int tur_check_async_timeout(struct checker *c)
a1c519
@@ -309,7 +318,9 @@ static int tur_check_async_timeout(struct checker *c)
a1c519
 	struct tur_checker_context *ct = c->context;
a1c519
 	struct timespec now;
a1c519
 
a1c519
-	clock_gettime(CLOCK_MONOTONIC, &now;;
a1c519
+	if (clock_gettime(CLOCK_MONOTONIC, &now) != 0)
a1c519
+		/* can't get time. assume we've timed out */
a1c519
+		return 1;
a1c519
 	return (now.tv_sec > ct->time);
a1c519
 }
a1c519
 
a1c519
-- 
a1c519
2.17.2
a1c519