bugfix for graph
cover bugfix for graph
This patchset contains two bugfixes for graph.
HongBo Zheng (2):
graph: fix memory leak
graph: fix dereferencing null pointer
lib/librte_graph/graph_stats.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
PATCH 2/2 graph: fix dereferencing null pointer
From: HongBo Zheng <[email protected]>
In function 'stats_mem_init', pointer 'stats' should be confirmed not null before memset it.
--- lib/librte_graph/graph_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_graph/graph_stats.c +1 -1
@@ -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 ;
Signature · 1 line
2.7.4
PATCH 1/2 graph: fix memory leak
In reply to Min Hu (Connor)From: HongBo Zheng <[email protected]>
Fix function 'stats_mem_populate' return without
free dynamic memory referenced by 'stats'.
--- lib/librte_graph/graph_stats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/librte_graph/graph_stats.c +3 -1
@@ -174,7 +174,7 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, cluster->stat.hz =rte_get_timer_hz (); node =graph_node_id_to_ptr (graph, id);if (node ==NULL ) -SET_ERR_JMP (ENOENT , err,"Failed to find node %s in graph %s" , +SET_ERR_JMP (ENOENT , free,"Failed to find node %s in graph %s" , graph_node->node->name, graph->name); cluster->nodes[cluster->nb_nodes++] = node;
@@ -183,6 +183,8 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, *stats_in = stats;return 0 ; +free: +free (stats); err:return -rte_errno; }
Signature · 1 line
2.7.4
Re: [dpdk-dev] [EXT] [PATCH 1/2] graph: fix memory leak
Quoted 52 lines
-----Original Message-----
From: Min Hu (Connor) <[email protected]>
Sent: Thursday, April 22, 2021 5:22 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>
Subject: [EXT] [PATCH 1/2] graph: fix memory leakExternal Email
----------------------------------------------------------------------
From: HongBo Zheng <[email protected]>Fix function '
stats_mem_populate' return without free dynamic memory referenced by 'stats'.Fixes af1ae8b6a32c ("graph: implement stats")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- lib/librte_graph/graph_stats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/librte_graph/graph_stats.c index renamed from lib/librte_graph/graph_stats.c +0
-0125e08d..f698bb3 100644
lib/librte_graph/graph_stats.c +1
-1@@ -174,7 +174,7 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, cluster->stat.hz =rte_get_timer_hz (); node =graph_node_id_to_ptr (graph, id);if (node ==NULL ) - SET_ERR_JMP(ENOENT, err, "Failed to find node %s in graph %s", + SET_ERR_JMP(ENOENT, free, "Failed to find node %s in graph %s",lib/librte_graph/graph_stats.c +2
-0graph_node->node->name, graph->name); cluster->nodes[cluster->nb_nodes++] = node;@@ -183,6 +183,8 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, *stats_in = stats;return 0 ; +free: +free (stats); err:return -rte_errno;
Quoted 3 lines
}
--
2.7.4
Re: [dpdk-dev] [EXT] [PATCH 2/2] graph: fix dereferencing null pointer
In reply to Min Hu (Connor)Quoted 41 lines
-----Original Message-----
From: Min Hu (Connor) <[email protected]>
Sent: Thursday, April 22, 2021 5:22 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>
Subject: [EXT] [PATCH 2/2] graph: fix dereferencing null pointerExternal Email
----------------------------------------------------------------------
From: HongBo Zheng <[email protected]>In function '
stats_mem_init', pointer 'stats' should be confirmed not null before memset it.Fixes af1ae8b6a32c ("graph: implement stats")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- lib/librte_graph/graph_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_graph/graph_stats.c index renamed from lib/librte_graph/graph_stats.c +0
-0f698bb3..bdc8652 100644
lib/librte_graph/graph_stats.c +1
-1@@ -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;
Quoted 3 lines
stats->max_nodes= 0;
--
2.7.4
Re: [dpdk-dev] [PATCH 2/2] graph: fix dereferencing null pointer
In reply to Min Hu (Connor)lib/librte_graph/graph_stats.c
Quoted 16 lines · Min Hu (Connor)
From: HongBo Zheng <[email protected]>
In function '
stats_mem_init', pointer 'stats' should be confirmed not null before memset it.Fixes af1ae8b6a32c ("graph: implement stats")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- lib/librte_graph/graph_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_graph/graph_stats.c +0
-0
The directory name is changed in upstream. Please rebase.
Quoted 16 lines
index f698bb3..bdc8652 100644
lib/librte_graph/graph_stats.c +1
-2@@ -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
Re: [dpdk-dev] [PATCH 1/2] graph: fix memory leak
In reply to Min Hu (Connor)Quoted 29 lines · Min Hu (Connor)
From: HongBo Zheng <[email protected]>
Fix function '
stats_mem_populate' return without
free dynamic memory referenced by 'stats'.Fixes af1ae8b6a32c ("graph: implement stats")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- lib/librte_graph/graph_stats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/librte_graph/graph_stats.c +1
-1@@ -174,7 +174,7 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, cluster->stat.hz =rte_get_timer_hz (); node =graph_node_id_to_ptr (graph, id);if (node ==NULL ) -SET_ERR_JMP (ENOENT , err,"Failed to find node %s in graph %s" , +SET_ERR_JMP (ENOENT , free,"Failed to find node %s in graph %s" , graph_node->node->name, graph->name); cluster->nodes[cluster->nb_nodes++] = node;
lib/librte_graph/graph_stats.c stats_mem_populate(struct rte_graph_cluster_stats **stats_in, · line 190
Quoted 8 lines
lib/librte_graph/graph_stats.c +2
-0@@ -183,6 +183,8 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, *stats_in = stats;return 0 ; +free: +free (stats); err:return -rte_errno; }
We have a double free with this change.
If realloc on stats returns the same location, but node lookup fails, stats_in is left untouched and still points at the original stats location.
This location is then freed in the free: label, and later is freed in stats_mem_fini() from caller.
Signature · 1 line
David Marchand
PATCH v2 2/2 graph: fix dereferencing null pointer
In reply to Min Hu (Connor)From: HongBo Zheng <[email protected]>
In function 'stats_mem_init', pointer 'stats' should be confirmed not null before memset it.
--- lib/graph/graph_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/graph/graph_stats.c +1 -1
@@ -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 ;
Signature · 1 line
2.7.4
PATCH v2 1/2 graph: fix memory leak
In reply to Min Hu (Connor)From: HongBo Zheng <[email protected]>
Fix function 'stats_mem_populate' return without
free dynamic memory referenced by 'stats'.
--- lib/graph/graph_stats.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/graph/graph_stats.c +4 -1
@@ -165,6 +165,7 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, stats =realloc (stats, stats->sz + stats->cluster_node_size);if (stats ==NULL )SET_ERR_JMP (ENOMEM , err,"Realloc failed" ); + *stats_in =NULL ;/* Clear the new struct cluster_node area */ cluster = RTE_PTR_ADD(stats, stats->sz),
@@ -174,7 +175,7 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, cluster->stat.hz =rte_get_timer_hz (); node =graph_node_id_to_ptr (graph, id);if (node ==NULL ) -SET_ERR_JMP (ENOENT , err,"Failed to find node %s in graph %s" , +SET_ERR_JMP (ENOENT , free,"Failed to find node %s in graph %s" , graph_node->node->name, graph->name); cluster->nodes[cluster->nb_nodes++] = node;
@@ -183,6 +184,8 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, *stats_in = stats;return 0 ; +free: +free (stats); err:return -rte_errno; }
Signature · 1 line
2.7.4
v2 cover bugfix for graph
In reply to Min Hu (Connor)This patchset contains two bugfixes for graph.
HongBo Zheng (2):
graph: fix memory leak
graph: fix dereferencing null pointer
lib/graph/graph_stats.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
---
v2:
* fix double free.
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 1/2] graph: fix memory leak
In reply to David MarchandQuoted 32 lines · David Marchand
Quoted 31 lines · Min Hu (Connor)
From: HongBo Zheng <[email protected]>
Fix function '
stats_mem_populate' return without
free dynamic memory referenced by 'stats'.Fixes af1ae8b6a32c ("graph: implement stats")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- lib/librte_graph/graph_stats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/librte_graph/graph_stats.c +1
-1@@ -174,7 +174,7 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, cluster->stat.hz =rte_get_timer_hz (); node =graph_node_id_to_ptr (graph, id);if (node ==NULL ) -SET_ERR_JMP (ENOENT , err,"Failed to find node %s in graph %s" , +SET_ERR_JMP (ENOENT , free,"Failed to find node %s in graph %s" , graph_node->node->name, graph->name); cluster->nodes[cluster->nb_nodes++] = node;@@ -183,6 +183,8 @@ stats_mem_populate(struct rte_graph_cluster_stats **stats_in, *stats_in = stats;
Quoted 9 lines
lib/librte_graph/graph_stats.c stats_mem_populate(struct rte_graph_cluster_stats **stats_in, · line 190
Quoted 6 lines
lib/librte_graph/graph_stats.c +2
-0return 0 ; +free: +free (stats); err:return -rte_errno; }We have a double free with this change.
Hi, David, I will set "*stats_in " to NULL.
As free(NULL) will just return and will not
result bugs.
Quoted 7 lines
If realloc on stats returns the same location, but node lookup fails,
stats_inis left untouched and still points at the original stats location.
This location is then freed in the free: label, and later is freed instats_mem_fini()from caller.
Re: [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer
In reply to Min Hu (Connor)Quoted 11 lines · Min Hu (Connor)
From: HongBo Zheng <[email protected]>
In function '
stats_mem_init', pointer 'stats' should be confirmed not null before memset it.Fixes af1ae8b6a32c ("graph: implement stats")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>
Quoted 21 lines
--- lib/graph/graph_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/graph/graph_stats.c +1
-2@@ -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
Re: [dpdk-dev] [PATCH v2 1/2] graph: fix memory leak
In reply to Min Hu (Connor)Quoted 11 lines · Min Hu (Connor)
From: HongBo Zheng <[email protected]>
Fix function '
stats_mem_populate' return without
free dynamic memory referenced by 'stats'.Fixes af1ae8b6a32c ("graph: implement stats")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer
In reply to Min Hu (Connor)Quoted 11 lines · Min Hu (Connor)
From: HongBo Zheng <[email protected]>
In function '
stats_mem_init', pointer 'stats' should be confirmed not null before memset it.Fixes af1ae8b6a32c ("graph: implement stats")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>
Signature · 1 line
David Marchand
Quoted 9 lines · Min Hu (Connor)
This patchset contains two bugfixes for graph.
HongBo Zheng (2):
graph: fix memory leak
graph: fix dereferencing null pointerlib/graph/graph_stats.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Series applied, thanks.
Signature · 1 line
David Marchand