[v2] app/testpmd: fix releasing action handle flush memory

Message ID 20240325105826.393231-1-bingz@nvidia.com (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers
Series [v2] app/testpmd: fix releasing action handle flush memory |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Bing Zhao March 25, 2024, 10:58 a.m. UTC
  The memory of the indirect action handles should be freed after
being destroyed in the flush. The behavior needs to be consistent
with the single handle destroy port_action_handle_destroy().

Or else, there would be some memory leak when closing / detaching a
port without quitting the application. In the meanwhile, since the
action handles are already destroyed, it makes no sense to hold the
indirect action software resources anymore.

Fixes: f7352c176bbf ("app/testpmd: fix use of indirect action after port close")
Cc: dmitry.kozliuk@gmail.com
Cc: stable@dpdk.org

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Reviewed-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
v2: update the description
---
 app/test-pmd/config.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
  

Comments

Ferruh Yigit April 18, 2024, 9:41 p.m. UTC | #1
On 3/25/2024 10:58 AM, Bing Zhao wrote:
> The memory of the indirect action handles should be freed after
> being destroyed in the flush. The behavior needs to be consistent
> with the single handle destroy port_action_handle_destroy().
> 
> Or else, there would be some memory leak when closing / detaching a
> port without quitting the application. In the meanwhile, since the
> action handles are already destroyed, it makes no sense to hold the
> indirect action software resources anymore.
> 
> Fixes: f7352c176bbf ("app/testpmd: fix use of indirect action after port close")
> Cc: dmitry.kozliuk@gmail.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bing Zhao <bingz@nvidia.com>
> Reviewed-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
>

Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index ba1007ace6..f62ba90c87 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1918,8 +1918,7 @@  port_action_handle_flush(portid_t port_id)
 		/* Poisoning to make sure PMDs update it in case of error. */
 		memset(&error, 0x44, sizeof(error));
 		if (pia->handle != NULL) {
-			ret = pia->type ==
-			      RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ?
+			ret = pia->type == RTE_FLOW_ACTION_TYPE_INDIRECT_LIST ?
 			      rte_flow_action_list_handle_destroy
 				      (port_id, pia->list_handle, &error) :
 			      rte_flow_action_handle_destroy
@@ -1929,11 +1928,9 @@  port_action_handle_flush(portid_t port_id)
 				       pia->id);
 				ret = port_flow_complain(&error);
 			}
-			tmp = &pia->next;
-		} else {
-			*tmp = pia->next;
-			free(pia);
 		}
+		*tmp = pia->next;
+		free(pia);
 	}
 	return ret;
 }