From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 04600A0C47;
	Tue, 26 Oct 2021 13:53:15 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 7B1CB40E0F;
	Tue, 26 Oct 2021 13:53:15 +0200 (CEST)
Received: from mga06.intel.com (mga06.intel.com [134.134.136.31])
 by mails.dpdk.org (Postfix) with ESMTP id 0E0B7407FF
 for <dev@dpdk.org>; Tue, 26 Oct 2021 13:53:12 +0200 (CEST)
X-IronPort-AV: E=McAfee;i="6200,9189,10148"; a="290720659"
X-IronPort-AV: E=Sophos;i="5.87,182,1631602800"; d="scan'208";a="290720659"
Received: from fmsmga007.fm.intel.com ([10.253.24.52])
 by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 26 Oct 2021 04:53:09 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.87,182,1631602800"; d="scan'208";a="494179359"
Received: from sivswdev08.ir.intel.com ([10.237.217.47])
 by fmsmga007.fm.intel.com with ESMTP; 26 Oct 2021 04:53:07 -0700
From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org, reshma.pattan@intel.com,
 Konstantin Ananyev <konstantin.ananyev@intel.com>
Date: Tue, 26 Oct 2021 12:53:01 +0100
Message-Id: <20211026115301.5456-1-konstantin.ananyev@intel.com>
X-Mailer: git-send-email 2.18.0
Subject: [dpdk-dev] [PATCH] pdump: fix uninit not freeing statistics memzone
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

rte_pdump_init() always allocates new memzone for pdump_stats.
Though rte_pdump_uninit() never frees it.
So the following combination will always fail:
rte_pdump_init(); rte_pdump_uninit(); rte_pdump_init();
The issue was caught by pdump_autotest UT.
While first test run successful, any consecutive runs
of this test-case will fail.
Fix the issue by calling rte_memzone_free() for statistics memzone.

Fixes: 10f726efe26c ("pdump: support pcapng and filtering")

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/pdump/rte_pdump.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c
index 71602685d5..a708935861 100644
--- a/lib/pdump/rte_pdump.c
+++ b/lib/pdump/rte_pdump.c
@@ -74,6 +74,7 @@ static const char MZ_RTE_PDUMP_STATS[] = "rte_pdump_stats";
 static struct {
 	struct rte_pdump_stats rx[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT];
 	struct rte_pdump_stats tx[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT];
+	const struct rte_memzone *mz;
 } *pdump_stats;
 
 /* Create a clone of mbuf to be placed into ring. */
@@ -429,6 +430,7 @@ rte_pdump_init(void)
 		return -1;
 	}
 	pdump_stats = mz->addr;
+	pdump_stats->mz = mz;
 
 	ret = rte_mp_action_register(PDUMP_MP, pdump_server);
 	if (ret && rte_errno != ENOTSUP)
@@ -441,6 +443,11 @@ rte_pdump_uninit(void)
 {
 	rte_mp_action_unregister(PDUMP_MP);
 
+	if (pdump_stats != NULL) {
+		rte_memzone_free(pdump_stats->mz);
+		pdump_stats = NULL;
+	}
+
 	return 0;
 }
 
-- 
2.26.3