diff mbox series

[v2,2/2] graph: fix dereferencing null pointer

Message ID 1620285387-42792-3-git-send-email-humin29@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers show
Series bugfix for graph | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/checkpatch success coding style OK

Commit Message

Min Hu (Connor) May 6, 2021, 7:16 a.m. UTC
From: HongBo Zheng <zhenghongbo3@huawei.com>

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 <zhenghongbo3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 lib/graph/graph_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jerin Jacob May 6, 2021, 9:01 a.m. UTC | #1
On Thu, May 6, 2021 at 12:46 PM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> From: HongBo Zheng <zhenghongbo3@huawei.com>
>
> 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 <zhenghongbo3@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>

Reviewed-by: Jerin Jacob <jerinj@marvell.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 30e295d..aa70929 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.7.4
>
David Marchand May 10, 2021, 1:27 p.m. UTC | #2
On Thu, May 6, 2021 at 9:16 AM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> From: HongBo Zheng <zhenghongbo3@huawei.com>
>
> 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 <zhenghongbo3@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>
diff mbox series

Patch

diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c
index 30e295d..aa70929 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;