From: Hongbo Zheng Date: Thu, 6 May 2021 07:16:27 +0000 (+0800) Subject: graph: fix null dereference in stats X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2d2bf7de1afe750984073c4cc81ffa4d95550811;p=dpdk.git graph: fix null dereference in stats In function 'stats_mem_init', pointer 'stats' should be confirmed not null before memset it. Fixes: af1ae8b6a32c ("graph: implement stats") Cc: stable@dpdk.org Signed-off-by: Hongbo Zheng Signed-off-by: Min Hu (Connor) Reviewed-by: Jerin Jacob Reviewed-by: David Marchand --- diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c index 30e295d8b1..aa70929dc3 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;