[dpdk-stable] [PATCH] graph_stats: do not use a possibly NULL Pointer

Thierry Herbelot thierry.herbelot at 6wind.com
Mon May 24 10:58:50 CEST 2021


Use stats only after it was checked not to be NULL.

Fixes: af1ae8b6a32c9 ("graph: implement stats")
Cc: stable at dpdk.org
Cc: Jerin Jacob <jerinj at marvell.com>
Cc: Kiran Kumar K <kirankumark at marvell.com>

Signed-off-by: Thierry Herbelot <thierry.herbelot at 6wind.com>
---
 lib/graph/graph_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c
index 125e08d73290..a52994f0f61e 100644
--- a/lib/graph/graph_stats.c
+++ b/lib/graph/graph_stats.c
@@ -119,8 +119,8 @@ stats_mem_init(struct cluster *cluster,
 	cluster_node_size = RTE_ALIGN(cluster_node_size, RTE_CACHE_LINE_SIZE);
 
 	stats = realloc(NULL, sz);
-	memset(stats, 0, sz);
 	if (stats) {
+		memset(stats, 0, sz);
 		stats->fn = fn;
 		stats->cluster_node_size = cluster_node_size;
 		stats->max_nodes = 0;
-- 
2.29.2



More information about the stable mailing list