From 847cbe34e8e45a0c0613cf5cd96f06ee31ada0f9 Mon Sep 17 00:00:00 2001
From: Changsheng Wu <wuchangsheng2@huawei.com>
Date: Sat, 18 Dec 2021 17:02:16 +0800
Subject: [PATCH] 0014

---
 lib/eal/common/eal_common_fbarray.c | 13 ++++++++-----
 lib/eal/linux/eal.c                 |  1 +
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c
index fa726cd2f5..b809d3c669 100644
--- a/lib/eal/common/eal_common_fbarray.c
+++ b/lib/eal/common/eal_common_fbarray.c
@@ -911,17 +911,20 @@ __rte_fbarray_attach(struct rte_fbarray *arr, const char *runtime_dir,
 		fd = -1;
 	}
 
-	/* store our new memory area */
-	ma->addr = data;
-	ma->fd = fd; /* keep fd until detach/destroy */
-	ma->len = mmap_len;
-
 	if (!internal_conf->pri_and_sec) {
+		/* store our new memory area */
+		ma->addr = data;
+		ma->fd = fd; /* keep fd until detach/destroy */
+		ma->len = mmap_len;
+
 		TAILQ_INSERT_TAIL(&mem_area_tailq, ma, next);
 
 		/* we're done */
 
 		rte_spinlock_unlock(&mem_area_lock);
+	} else {
+		/* pri_and_sec don't use mem_area_tailq */
+		free(ma);
 	}
 	return 0;
 fail:
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index f70c4d55fa..2dee945be4 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -564,6 +564,7 @@ eal_sec_config_cleanup(const int sec_idx)
 	}
 
 	memset(lc_rte_cfg, 0, sizeof(*lc_rte_cfg));
+	eal_cleanup_config(lc_internal_cfg);
 	memset(lc_internal_cfg, 0, sizeof(*lc_internal_cfg));
 	memset(lc_runtime_dir, 0, PATH_MAX);
 
-- 
2.27.0

