Blame SOURCES/0002-libmultipath-fix-leak-in-foreign-code.patch

8444ee
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8444ee
From: Benjamin Marzinski <bmarzins@redhat.com>
8444ee
Date: Mon, 7 Oct 2019 17:17:13 -0500
8444ee
Subject: [PATCH] libmultipath: fix leak in foreign code
8444ee
8444ee
If scandir fails or finds no foreign libraries, enable_re needs to be
8444ee
freed before exitting.
8444ee
8444ee
Fixes: 8d03eda4 'multipath.conf: add "enable_foreign" parameter'
8444ee
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
8444ee
---
8444ee
 libmultipath/foreign.c | 11 +++++++----
8444ee
 1 file changed, 7 insertions(+), 4 deletions(-)
8444ee
8444ee
diff --git a/libmultipath/foreign.c b/libmultipath/foreign.c
8444ee
index 4b34e141..68e9a9b8 100644
8444ee
--- a/libmultipath/foreign.c
8444ee
+++ b/libmultipath/foreign.c
8444ee
@@ -129,7 +129,7 @@ static int _init_foreign(const char *multipath_dir, const char *enable)
8444ee
 	char pathbuf[PATH_MAX];
8444ee
 	struct dirent **di;
8444ee
 	struct scandir_result sr;
8444ee
-	int r, i;
8444ee
+	int r, i, ret = 0;
8444ee
 	regex_t *enable_re = NULL;
8444ee
 
8444ee
 	foreigns = vector_alloc();
8444ee
@@ -157,13 +157,15 @@ static int _init_foreign(const char *multipath_dir, const char *enable)
8444ee
 	if (r == 0) {
8444ee
 		condlog(3, "%s: no foreign multipath libraries found",
8444ee
 			__func__);
8444ee
-		return 0;
8444ee
+		ret = 0;
8444ee
+		goto out;
8444ee
 	} else if (r < 0) {
8444ee
 		r = errno;
8444ee
 		condlog(1, "%s: error %d scanning foreign multipath libraries",
8444ee
 			__func__, r);
8444ee
 		_cleanup_foreign();
8444ee
-		return -r;
8444ee
+		ret = -r;
8444ee
+		goto out;
8444ee
 	}
8444ee
 
8444ee
 	sr.di = di;
8444ee
@@ -250,8 +252,9 @@ static int _init_foreign(const char *multipath_dir, const char *enable)
8444ee
 		free_foreign(fgn);
8444ee
 	}
8444ee
 	pthread_cleanup_pop(1); /* free_scandir_result */
8444ee
+out:
8444ee
 	pthread_cleanup_pop(1); /* free_pre */
8444ee
-	return 0;
8444ee
+	return ret;
8444ee
 }
8444ee
 
8444ee
 int init_foreign(const char *multipath_dir, const char *enable)
8444ee
-- 
8444ee
2.17.2
8444ee