From 813e144a197bf6cad562c9163b34ac3c296094e1 Mon Sep 17 00:00:00 2001 From: Tuomas Taipale Date: Mon, 18 Sep 2023 12:48:50 +0000 Subject: [PATCH] test: ipsecfwd: fix potential memory leak When tearing down resources, free interface string unconditionally as teardown logic could be reached before packet I/Os have been opened. Signed-off-by: Tuomas Taipale Reviewed-by: Janne Peltonen --- test/performance/odp_ipsecfwd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/performance/odp_ipsecfwd.c b/test/performance/odp_ipsecfwd.c index ecc6010329..d2441a4167 100644 --- a/test/performance/odp_ipsecfwd.c +++ b/test/performance/odp_ipsecfwd.c @@ -1933,11 +1933,12 @@ static void teardown_test(const prog_config_t *config) { (void)odph_iplookup_table_destroy(config->fwd_tbl); - for (uint32_t i = 0U; i < config->num_ifs; ++i) - if (config->pktios[i].handle != ODP_PKTIO_INVALID) { + for (uint32_t i = 0U; i < config->num_ifs; ++i) { + free(config->pktios[i].name); + + if (config->pktios[i].handle != ODP_PKTIO_INVALID) (void)odp_pktio_close(config->pktios[i].handle); - free(config->pktios[i].name); - } + } if (config->pktio_pool != ODP_POOL_INVALID) (void)odp_pool_destroy(config->pktio_pool);