[06/13] app/flow-perf: fix memory leak from RSS action

Message ID 20200830111544.4190-7-wisamm@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series app/flow-perf: add support for new items/actions |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Wisam Jaddo Aug. 30, 2020, 11:15 a.m. UTC
  Currently, each call for add_rss_action will allocate
extra memory for rss_data, which will reflect bad results
on memory consumption for all flows, and will leads into
memory leak.

In this fix, it will check if it's allocated before
reallocating it.

Fixes: bf3688f1e816 ("app/flow-perf: add insertion rate calculation")
Cc: wisamm@mellanox.com

Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
Acked-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
 app/test-flow-perf/actions_gen.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Patch

diff --git a/app/test-flow-perf/actions_gen.c b/app/test-flow-perf/actions_gen.c
index 9fe11abc94..99e47bf786 100644
--- a/app/test-flow-perf/actions_gen.c
+++ b/app/test-flow-perf/actions_gen.c
@@ -86,8 +86,9 @@  add_rss(struct rte_flow_action *actions,
 
 	uint16_t queue;
 
-	rss_data = rte_malloc("rss_data",
-		sizeof(struct action_rss_data), 0);
+	if (rss_data == NULL)
+		rss_data = rte_malloc("rss_data",
+			sizeof(struct action_rss_data), 0);
 
 	if (rss_data == NULL)
 		rte_exit(EXIT_FAILURE, "No Memory available!");