]> git.droids-corp.org - dpdk.git/commitdiff
pdump: fix freeing statistics memzone
authorKonstantin Ananyev <konstantin.ananyev@intel.com>
Tue, 26 Oct 2021 11:53:01 +0000 (12:53 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 3 Nov 2021 11:53:03 +0000 (12:53 +0100)
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>
Acked-by: Reshma Pattan <reshma.pattan@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
lib/pdump/rte_pdump.c

index 3086b2a1688b168dd37c1b939d22554522babf43..af450695ecafdc7a7f33085dc8da21ba2f5f8bc4 100644 (file)
@@ -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;
 }