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