test/graph_perf: fix memory leaks

Message ID 20200513205600.6584-1-pbhagavatula@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series test/graph_perf: fix memory leaks |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues

Commit Message

Pavan Nikhilesh Bhagavatula May 13, 2020, 8:56 p.m. UTC
  From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Fix memory leaks reported by coverity.

Coverity issue: 358440, 358441, 358446.
Fixes: 61d77071ab99 ("test/graph: add performance tests")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 app/test/test_graph_perf.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Jerin Jacob May 15, 2020, 5:26 a.m. UTC | #1
On Thu, May 14, 2020 at 2:26 AM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Fix memory leaks reported by coverity.
>
> Coverity issue: 358440, 358441, 358446.

The last dot can be removed when merging.


> Fixes: 61d77071ab99 ("test/graph: add performance tests")
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>


Acked-by: Jerin Jacob <jerinj@marvell.com>



> ---
>  app/test/test_graph_perf.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/app/test/test_graph_perf.c b/app/test/test_graph_perf.c
> index 3089fb24c..296d99a9d 100644
> --- a/app/test/test_graph_perf.c
> +++ b/app/test/test_graph_perf.c
> @@ -76,6 +76,8 @@ test_node_ctx_init(const struct rte_graph *graph, struct rte_node *node)
>         RTE_SET_USED(graph);
>
>         mz = rte_memzone_lookup(TEST_GRAPH_PERF_MZ);
> +       if (mz == NULL)
> +               return -ENOMEM;
>         graph_data = mz->addr;
>         node_data = graph_get_node_data(graph_data, nid);
>         node->ctx[0] = node->nb_edges;
> @@ -570,6 +572,7 @@ graph_init(const char *gname, uint8_t nb_srcs, uint8_t nb_sinks,
>         }
>         graph_data->graph_id = graph_id;
>
> +       free(node_map);
>         for (i = 0; i < graph_data->nb_nodes; i++)
>                 free(node_patterns[i]);
>         free(snk_nodes);
> @@ -578,6 +581,7 @@ graph_init(const char *gname, uint8_t nb_srcs, uint8_t nb_sinks,
>         return 0;
>
>  pattern_name_free:
> +       free(node_map);
>         for (i = 0; i < graph_data->nb_nodes; i++)
>                 free(node_patterns[i]);
>  snk_free:
> @@ -677,6 +681,8 @@ measure_perf(void)
>         struct test_graph_perf *graph_data;
>
>         mz = rte_memzone_lookup(TEST_GRAPH_PERF_MZ);
> +       if (mz == NULL)
> +               return -ENOMEM;
>         graph_data = mz->addr;
>
>         return measure_perf_get(graph_data->graph_id);
> --
> 2.26.2
>
  
David Marchand May 15, 2020, 8:13 a.m. UTC | #2
On Wed, May 13, 2020 at 10:56 PM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Fix memory leaks reported by coverity.
>
> Coverity issue: 358440, 358441, 358446
> Fixes: 61d77071ab99 ("test/graph: add performance tests")
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>

Applied, thanks.
  

Patch

diff --git a/app/test/test_graph_perf.c b/app/test/test_graph_perf.c
index 3089fb24c..296d99a9d 100644
--- a/app/test/test_graph_perf.c
+++ b/app/test/test_graph_perf.c
@@ -76,6 +76,8 @@  test_node_ctx_init(const struct rte_graph *graph, struct rte_node *node)
 	RTE_SET_USED(graph);
 
 	mz = rte_memzone_lookup(TEST_GRAPH_PERF_MZ);
+	if (mz == NULL)
+		return -ENOMEM;
 	graph_data = mz->addr;
 	node_data = graph_get_node_data(graph_data, nid);
 	node->ctx[0] = node->nb_edges;
@@ -570,6 +572,7 @@  graph_init(const char *gname, uint8_t nb_srcs, uint8_t nb_sinks,
 	}
 	graph_data->graph_id = graph_id;
 
+	free(node_map);
 	for (i = 0; i < graph_data->nb_nodes; i++)
 		free(node_patterns[i]);
 	free(snk_nodes);
@@ -578,6 +581,7 @@  graph_init(const char *gname, uint8_t nb_srcs, uint8_t nb_sinks,
 	return 0;
 
 pattern_name_free:
+	free(node_map);
 	for (i = 0; i < graph_data->nb_nodes; i++)
 		free(node_patterns[i]);
 snk_free:
@@ -677,6 +681,8 @@  measure_perf(void)
 	struct test_graph_perf *graph_data;
 
 	mz = rte_memzone_lookup(TEST_GRAPH_PERF_MZ);
+	if (mz == NULL)
+		return -ENOMEM;
 	graph_data = mz->addr;
 
 	return measure_perf_get(graph_data->graph_id);