Skip to contentSkip to conversation

test/graph: fix memory leak

PATCH Superseded [email protected] 3 participants 7 messages May 14, 2020 – May 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/graph: fix memory leak

From: Kiran Kumar K <[email protected]>

Fix memory leaks reported by coverity.

---
 app/test/test_graph.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
app/test/test_graph.c +5 -2
index cf6df0744..ed69eda99 100644
@@ -12,6 +12,7 @@
 #include <rte_graph.h>
 #include <rte_graph_worker.h>
 #include <rte_mbuf.h>
+#include <rte_random.h>
 
 #include "test.h"
 
@@ -145,7 +146,7 @@ uint16_t
 test_node_worker_source(struct rte_graph *graph, struct rte_node *node,
 			void **objs, uint16_t nb_objs)
 {
-	uint32_t obj_node0 = rand() % 100, obj_node1;
+	uint32_t obj_node0 = rte_rand() % 100, obj_node1;
 	test_main_t *tm = &test_main;
 	struct rte_mbuf *data;
 	void **next_stream;
@@ -193,7 +194,7 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 	test_main_t *tm = &test_main;
 
 	if (*(uint32_t *)node->ctx == test_node0.id) {
-		uint32_t obj_node0 = rand() % 100, obj_node1;
+		uint32_t obj_node0 = rte_rand() % 100, obj_node1;
 		struct rte_mbuf *data;
 		uint8_t second_pass = 0;
 		uint32_t count = 0;
@@ -496,6 +497,7 @@ test_lookup_functions(void)
 			printf("Test number of edges for node = %s failed Expected = %d, got %d\n",
 			       tm->test_node[i].node.name,
 			       tm->test_node[i].node.nb_edges, count);
+			free(next_edges);
 			return -1;
 		}
 
@@ -505,6 +507,7 @@ test_lookup_functions(void)
 				printf("Edge name miss match, expected = %s got = %s\n",
 				       tm->test_node[i].node.next_nodes[j],
 				       next_edges[j]);
+				free(next_edges);
 				return -1;
 			}
 		}
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · On Thu, May 14, 2020 at 9:02 AM <[email protected]> wrote:

From: Kiran Kumar K <[email protected]>

Fix memory leaks reported by coverity.

Please add Coverity issue: and Fixes: tag

Quoted 55 lines
---
 app/test/test_graph.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
app/test/test_graph.c +5 -3
index cf6df0744..ed69eda99 100644
@@ -12,6 +12,7 @@
 #include <rte_graph.h>
 #include <rte_graph_worker.h>
 #include <rte_mbuf.h>
+#include <rte_random.h>
 
 #include "test.h"
 
@@ -145,7 +146,7 @@ uint16_t
 test_node_worker_source(struct rte_graph *graph, struct rte_node *node,
                        void **objs, uint16_t nb_objs)
 {
-       uint32_t obj_node0 = rand() % 100, obj_node1;
+       uint32_t obj_node0 = rte_rand() % 100, obj_node1;
        test_main_t *tm = &test_main;
        struct rte_mbuf *data;
        void **next_stream;
@@ -193,7 +194,7 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
        test_main_t *tm = &test_main;
 
        if (*(uint32_t *)node->ctx == test_node0.id) {
-               uint32_t obj_node0 = rand() % 100, obj_node1;
+               uint32_t obj_node0 = rte_rand() % 100, obj_node1;
                struct rte_mbuf *data;
                uint8_t second_pass = 0;
                uint32_t count = 0;
@@ -496,6 +497,7 @@ test_lookup_functions(void)
                        printf("Test number of edges for node = %s failed Expected = %d, got %d\n",
                               tm->test_node[i].node.name,
                               tm->test_node[i].node.nb_edges, count);
+                       free(next_edges);
                        return -1;
                }
 
@@ -505,6 +507,7 @@ test_lookup_functions(void)
                                printf("Edge name miss match, expected = %s got = %s\n",
                                       tm->test_node[i].node.next_nodes[j],
                                       next_edges[j]);
+                               free(next_edges);
                                return -1;
                        }
                }
--

2.17.1

#2 lore raw

PATCH v2 1/1 test/graph: fix memory leak

In reply to [email protected]

From: Kiran Kumar K <[email protected]>

Fix memory leaks reported by coverity.

Coverity issue: 358439, 358451, 358448.

Fixes 6b89650418("test/graph: add functional tests")

---
V2 changes:
* Added Coverity issue and Fixes info.

 app/test/test_graph.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
app/test/test_graph.c +5 -2
index cf6df0744..ed69eda99 100644
@@ -12,6 +12,7 @@
 #include <rte_graph.h>
 #include <rte_graph_worker.h>
 #include <rte_mbuf.h>
+#include <rte_random.h>
 
 #include "test.h"
 
@@ -145,7 +146,7 @@ uint16_t
 test_node_worker_source(struct rte_graph *graph, struct rte_node *node,
 			void **objs, uint16_t nb_objs)
 {
-	uint32_t obj_node0 = rand() % 100, obj_node1;
+	uint32_t obj_node0 = rte_rand() % 100, obj_node1;
 	test_main_t *tm = &test_main;
 	struct rte_mbuf *data;
 	void **next_stream;
@@ -193,7 +194,7 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 	test_main_t *tm = &test_main;
 
 	if (*(uint32_t *)node->ctx == test_node0.id) {
-		uint32_t obj_node0 = rand() % 100, obj_node1;
+		uint32_t obj_node0 = rte_rand() % 100, obj_node1;
 		struct rte_mbuf *data;
 		uint8_t second_pass = 0;
 		uint32_t count = 0;
@@ -496,6 +497,7 @@ test_lookup_functions(void)
 			printf("Test number of edges for node = %s failed Expected = %d, got %d\n",
 			       tm->test_node[i].node.name,
 			       tm->test_node[i].node.nb_edges, count);
+			free(next_edges);
 			return -1;
 		}
 
@@ -505,6 +507,7 @@ test_lookup_functions(void)
 				printf("Edge name miss match, expected = %s got = %s\n",
 				       tm->test_node[i].node.next_nodes[j],
 				       next_edges[j]);
+				free(next_edges);
 				return -1;
 			}
 		}

--
2.17.1

#3 lore raw

PATCH v3 1/1 test/graph: fix coverity issues

From: Kiran Kumar K <[email protected]>

Fix memory leak and weak crypto issues reported by coverity.

Coverity issue: 358439, 358448, 358451

Fixes 6b89650418("test/graph: add functional tests")
---
 app/test/test_graph.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
app/test/test_graph.c +5 -2
index cf6df0744..ed69eda99 100644
@@ -12,6 +12,7 @@
 #include <rte_graph.h>
 #include <rte_graph_worker.h>
 #include <rte_mbuf.h>
+#include <rte_random.h>
 
 #include "test.h"
 
@@ -145,7 +146,7 @@ uint16_t
 test_node_worker_source(struct rte_graph *graph, struct rte_node *node,
 			void **objs, uint16_t nb_objs)
 {
-	uint32_t obj_node0 = rand() % 100, obj_node1;
+	uint32_t obj_node0 = rte_rand() % 100, obj_node1;
 	test_main_t *tm = &test_main;
 	struct rte_mbuf *data;
 	void **next_stream;
@@ -193,7 +194,7 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 	test_main_t *tm = &test_main;
 
 	if (*(uint32_t *)node->ctx == test_node0.id) {
-		uint32_t obj_node0 = rand() % 100, obj_node1;
+		uint32_t obj_node0 = rte_rand() % 100, obj_node1;
 		struct rte_mbuf *data;
 		uint8_t second_pass = 0;
 		uint32_t count = 0;
@@ -496,6 +497,7 @@ test_lookup_functions(void)
 			printf("Test number of edges for node = %s failed Expected = %d, got %d\n",
 			       tm->test_node[i].node.name,
 			       tm->test_node[i].node.nb_edges, count);
+			free(next_edges);
 			return -1;
 		}
 
@@ -505,6 +507,7 @@ test_lookup_functions(void)
 				printf("Edge name miss match, expected = %s got = %s\n",
 				       tm->test_node[i].node.next_nodes[j],
 				       next_edges[j]);
+				free(next_edges);
 				return -1;
 			}
 		}
Signature · 1 line
2.17.1
Acked-by on v3 1/1
#4 lore raw

Re: [dpdk-dev] [PATCH v3] test/graph: fix coverity issues

Quoted 7 lines · On Thu, May 14, 2020 at 4:56 PM <[email protected]> wrote:

From: Kiran Kumar K <[email protected]>

Fix memory leak and weak crypto issues reported by coverity.

Coverity issue: 358439, 358448, 358451

Fixes 6b89650418("test/graph: add functional tests")

Space is missing before the opening bracket due to that checkpatch is failing.

With above change:

Quoted 55 lines
---
 app/test/test_graph.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
app/test/test_graph.c +5 -3
index cf6df0744..ed69eda99 100644
@@ -12,6 +12,7 @@
 #include <rte_graph.h>
 #include <rte_graph_worker.h>
 #include <rte_mbuf.h>
+#include <rte_random.h>
 
 #include "test.h"
 
@@ -145,7 +146,7 @@ uint16_t
 test_node_worker_source(struct rte_graph *graph, struct rte_node *node,
                        void **objs, uint16_t nb_objs)
 {
-       uint32_t obj_node0 = rand() % 100, obj_node1;
+       uint32_t obj_node0 = rte_rand() % 100, obj_node1;
        test_main_t *tm = &test_main;
        struct rte_mbuf *data;
        void **next_stream;
@@ -193,7 +194,7 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
        test_main_t *tm = &test_main;
 
        if (*(uint32_t *)node->ctx == test_node0.id) {
-               uint32_t obj_node0 = rand() % 100, obj_node1;
+               uint32_t obj_node0 = rte_rand() % 100, obj_node1;
                struct rte_mbuf *data;
                uint8_t second_pass = 0;
                uint32_t count = 0;
@@ -496,6 +497,7 @@ test_lookup_functions(void)
                        printf("Test number of edges for node = %s failed Expected = %d, got %d\n",
                               tm->test_node[i].node.name,
                               tm->test_node[i].node.nb_edges, count);
+                       free(next_edges);
                        return -1;
                }
 
@@ -505,6 +507,7 @@ test_lookup_functions(void)
                                printf("Edge name miss match, expected = %s got = %s\n",
                                       tm->test_node[i].node.next_nodes[j],
                                       next_edges[j]);
+                               free(next_edges);
                                return -1;
                        }
                }
--

2.17.1

#5 lore raw

PATCH v4 1/1 test/graph: fix coverity issues

In reply to [email protected]

From: Kiran Kumar K <[email protected]>

Fix memory leak and weak crypto issues reported by coverity.

Coverity issue: 358439, 358448, 358451

Fixes 6b89650418 ("test/graph: add functional tests")

---
V4 Changes:
* Added space before bracket in Fixes.

 app/test/test_graph.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
app/test/test_graph.c +5 -2
index cf6df0744..ed69eda99 100644
@@ -12,6 +12,7 @@
 #include <rte_graph.h>
 #include <rte_graph_worker.h>
 #include <rte_mbuf.h>
+#include <rte_random.h>
 
 #include "test.h"
 
@@ -145,7 +146,7 @@ uint16_t
 test_node_worker_source(struct rte_graph *graph, struct rte_node *node,
 			void **objs, uint16_t nb_objs)
 {
-	uint32_t obj_node0 = rand() % 100, obj_node1;
+	uint32_t obj_node0 = rte_rand() % 100, obj_node1;
 	test_main_t *tm = &test_main;
 	struct rte_mbuf *data;
 	void **next_stream;
@@ -193,7 +194,7 @@ test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,
 	test_main_t *tm = &test_main;
 
 	if (*(uint32_t *)node->ctx == test_node0.id) {
-		uint32_t obj_node0 = rand() % 100, obj_node1;
+		uint32_t obj_node0 = rte_rand() % 100, obj_node1;
 		struct rte_mbuf *data;
 		uint8_t second_pass = 0;
 		uint32_t count = 0;
@@ -496,6 +497,7 @@ test_lookup_functions(void)
 			printf("Test number of edges for node = %s failed Expected = %d, got %d\n",
 			       tm->test_node[i].node.name,
 			       tm->test_node[i].node.nb_edges, count);
+			free(next_edges);
 			return -1;
 		}
 
@@ -505,6 +507,7 @@ test_lookup_functions(void)
 				printf("Edge name miss match, expected = %s got = %s\n",
 				       tm->test_node[i].node.next_nodes[j],
 				       next_edges[j]);
+				free(next_edges);
 				return -1;
 			}
 		}

--
2.17.1

#6 lore raw

Re: [dpdk-dev] [PATCH v4] test/graph: fix coverity issues

Quoted 10 lines · On Fri, May 15, 2020 at 9:29 AM <[email protected]> wrote:

From: Kiran Kumar K <[email protected]>

Fix memory leak and weak crypto issues reported by coverity.

Coverity issue: 358439, 358448, 358451

Fixes 6b89650418 ("test/graph: add functional tests")

Applied, thanks.

Signature · 1 line
David Marchand