device-mapper-multipath/0014-multipath-free-vectors-in-configure.patch
Benjamin Marzinski 4cd78d0f27 device-mapper-multipath-0.8.6-3
Add 0011-multipathd-don-t-fail-to-remove-path-once-the-map-is.patch
Add 0012-multipathd-remove-duplicate-orphan_paths-in-flush_ma.patch
Add 0013-multipathd-fix-ev_remove_path-return-code-handling.patch
Add 0014-multipath-free-vectors-in-configure.patch
Add 0015-kpartx-Don-t-leak-memory-when-getblock-returns-NULL.patch
Add 0016-multipathd-don-t-rescan_path-on-wwid-change-in-uev_u.patch
  * Above patches Fix bz #1938704
Resolves: bz #1938704
2021-05-19 17:16:17 -05:00

47 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Tue, 11 May 2021 15:25:21 -0500
Subject: [PATCH] multipath: free vectors in configure
configure() can retry multiple times, each time reallocing a maps and
paths vector, and leaking the previous ones. Fix this by always freeing
the vectors before configure() exits. Found by coverity.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipath/main.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/multipath/main.c b/multipath/main.c
index f618550d..9fe53dcd 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -512,7 +512,6 @@ configure (struct config *conf, enum mpath_cmds cmd,
*/
curmp = vector_alloc();
pathvec = vector_alloc();
- atexit(cleanup_vecs);
if (!curmp || !pathvec) {
condlog(0, "can not allocate memory");
@@ -624,6 +623,11 @@ out:
if (refwwid)
FREE(refwwid);
+ free_multipathvec(curmp, KEEP_PATHS);
+ vecs.mpvec = NULL;
+ free_pathvec(pathvec, FREE_PATHS);
+ vecs.pathvec = NULL;
+
return r;
}
@@ -869,6 +873,7 @@ main (int argc, char *argv[])
conf = get_multipath_config();
conf->retrigger_tries = 0;
conf->force_sync = 1;
+ atexit(cleanup_vecs);
while ((arg = getopt(argc, argv, ":aAdDcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) {
switch(arg) {
case 1: printf("optarg : %s\n",optarg);