net/bnxt: fix null dereference in session cleanup
[dpdk.git] / app / test / test_graph_perf.c
index 3089fb2..1d06543 100644 (file)
@@ -1,6 +1,9 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(C) 2020 Marvell International Ltd.
  */
+
+#include "test.h"
+
 #include <inttypes.h>
 #include <signal.h>
 #include <stdio.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
 #include <rte_errno.h>
+#ifdef RTE_EXEC_ENV_WINDOWS
+static int
+test_graph_perf_func(void)
+{
+       printf("graph_perf not supported on Windows, skipping test\n");
+       return TEST_SKIPPED;
+}
+
+#else
+
 #include <rte_graph.h>
 #include <rte_graph_worker.h>
 #include <rte_lcore.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
 
-#include "test.h"
-
 #define TEST_GRAPH_PERF_MZ          "graph_perf_data"
 #define TEST_GRAPH_SRC_NAME         "test_graph_perf_source"
 #define TEST_GRAPH_SRC_BRST_ONE_NAME "test_graph_perf_source_one"
@@ -76,6 +87,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 +583,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 +592,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 +692,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);
@@ -1054,4 +1071,6 @@ test_graph_perf_func(void)
        return unit_test_suite_runner(&graph_perf_testsuite);
 }
 
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
 REGISTER_TEST_COMMAND(graph_perf_autotest, test_graph_perf_func);