All of lore.kernel.org
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] bugfix for graph
@ 2021-04-22 11:52 Min Hu (Connor)
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 1/2] graph: fix memory leak Min Hu (Connor)
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Min Hu (Connor) @ 2021-04-22 11:52 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, jerinj, kirankumark

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(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [dpdk-dev] [PATCH 1/2] graph: fix memory leak
  2021-04-22 11:52 [dpdk-dev] [PATCH 0/2] bugfix for graph Min Hu (Connor)
@ 2021-04-22 11:52 ` Min Hu (Connor)
  2021-04-23  3:52   ` [dpdk-dev] [EXT] " Kiran Kumar Kokkilagadda
  2021-05-04 14:15   ` [dpdk-dev] " David Marchand
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
  2021-05-06  7:16 ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph Min Hu (Connor)
  2 siblings, 2 replies; 15+ messages in thread
From: Min Hu (Connor) @ 2021-04-22 11:52 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, jerinj, kirankumark

From: HongBo Zheng <zhenghongbo3@huawei.com>

Fix function 'stats_mem_populate' return without
free dynamic memory referenced by 'stats'.

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/librte_graph/graph_stats.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_graph/graph_stats.c b/lib/librte_graph/graph_stats.c
index 125e08d..f698bb3 100644
--- a/lib/librte_graph/graph_stats.c
+++ b/lib/librte_graph/graph_stats.c
@@ -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;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [dpdk-dev] [PATCH 2/2] graph: fix dereferencing null pointer
  2021-04-22 11:52 [dpdk-dev] [PATCH 0/2] bugfix for graph Min Hu (Connor)
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 1/2] graph: fix memory leak Min Hu (Connor)
@ 2021-04-22 11:52 ` Min Hu (Connor)
  2021-04-23  3:52   ` [dpdk-dev] [EXT] " Kiran Kumar Kokkilagadda
  2021-04-23  9:05   ` [dpdk-dev] " Jerin Jacob
  2021-05-06  7:16 ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph Min Hu (Connor)
  2 siblings, 2 replies; 15+ messages in thread
From: Min Hu (Connor) @ 2021-04-22 11:52 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, jerinj, kirankumark

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/librte_graph/graph_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_graph/graph_stats.c b/lib/librte_graph/graph_stats.c
index f698bb3..bdc8652 100644
--- a/lib/librte_graph/graph_stats.c
+++ b/lib/librte_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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [EXT] [PATCH 1/2] graph: fix memory leak
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 1/2] graph: fix memory leak Min Hu (Connor)
@ 2021-04-23  3:52   ` Kiran Kumar Kokkilagadda
  2021-05-04 14:15   ` [dpdk-dev] " David Marchand
  1 sibling, 0 replies; 15+ messages in thread
From: Kiran Kumar Kokkilagadda @ 2021-04-23  3:52 UTC (permalink / raw)
  To: Min Hu (Connor), dev; +Cc: ferruh.yigit, Jerin Jacob Kollanukkaran



> -----Original Message-----
> From: Min Hu (Connor) <humin29@huawei.com>
> Sent: Thursday, April 22, 2021 5:22 PM
> To: dev@dpdk.org
> Cc: ferruh.yigit@intel.com; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> Kiran Kumar Kokkilagadda <kirankumark@marvell.com>
> Subject: [EXT] [PATCH 1/2] graph: fix memory leak
> 
> External Email
> 
> ----------------------------------------------------------------------
> From: HongBo Zheng <zhenghongbo3@huawei.com>
> 
> Fix function 'stats_mem_populate' return without free dynamic memory
> referenced by 'stats'.
> 
> 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/librte_graph/graph_stats.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_graph/graph_stats.c b/lib/librte_graph/graph_stats.c index
> 125e08d..f698bb3 100644
> --- a/lib/librte_graph/graph_stats.c
> +++ b/lib/librte_graph/graph_stats.c
> @@ -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;
>  }
> --
> 2.7.4


Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [EXT] [PATCH 2/2] graph: fix dereferencing null pointer
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
@ 2021-04-23  3:52   ` Kiran Kumar Kokkilagadda
  2021-04-23  9:05   ` [dpdk-dev] " Jerin Jacob
  1 sibling, 0 replies; 15+ messages in thread
From: Kiran Kumar Kokkilagadda @ 2021-04-23  3:52 UTC (permalink / raw)
  To: Min Hu (Connor), dev; +Cc: ferruh.yigit, Jerin Jacob Kollanukkaran



> -----Original Message-----
> From: Min Hu (Connor) <humin29@huawei.com>
> Sent: Thursday, April 22, 2021 5:22 PM
> To: dev@dpdk.org
> Cc: ferruh.yigit@intel.com; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> Kiran Kumar Kokkilagadda <kirankumark@marvell.com>
> Subject: [EXT] [PATCH 2/2] graph: fix dereferencing null pointer
> 
> External Email
> 
> ----------------------------------------------------------------------
> 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/librte_graph/graph_stats.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_graph/graph_stats.c b/lib/librte_graph/graph_stats.c index
> f698bb3..bdc8652 100644
> --- a/lib/librte_graph/graph_stats.c
> +++ b/lib/librte_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

Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] graph: fix dereferencing null pointer
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
  2021-04-23  3:52   ` [dpdk-dev] [EXT] " Kiran Kumar Kokkilagadda
@ 2021-04-23  9:05   ` Jerin Jacob
  1 sibling, 0 replies; 15+ messages in thread
From: Jerin Jacob @ 2021-04-23  9:05 UTC (permalink / raw)
  To: Min Hu (Connor); +Cc: dpdk-dev, Ferruh Yigit, Jerin Jacob, Kiran Kumar K

On Thu, Apr 22, 2021 at 5:22 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>
> ---
>  lib/librte_graph/graph_stats.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_graph/graph_stats.c b/lib/librte_graph/graph_stats.c

The directory name is changed in upstream. Please rebase.

Acked-by: Jerin Jacob <jerinj@marvell.com>




> index f698bb3..bdc8652 100644
> --- a/lib/librte_graph/graph_stats.c
> +++ b/lib/librte_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
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] graph: fix memory leak
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 1/2] graph: fix memory leak Min Hu (Connor)
  2021-04-23  3:52   ` [dpdk-dev] [EXT] " Kiran Kumar Kokkilagadda
@ 2021-05-04 14:15   ` David Marchand
  2021-05-06  7:18     ` Min Hu (Connor)
  1 sibling, 1 reply; 15+ messages in thread
From: David Marchand @ 2021-05-04 14:15 UTC (permalink / raw)
  To: Min Hu (Connor)
  Cc: dev, Yigit, Ferruh, Jerin Jacob Kollanukkaran, Kiran Kumar Kokkilagadda

On Thu, Apr 22, 2021 at 1:52 PM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> From: HongBo Zheng <zhenghongbo3@huawei.com>
>
> Fix function 'stats_mem_populate' return without
> free dynamic memory referenced by 'stats'.
>
> 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/librte_graph/graph_stats.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_graph/graph_stats.c b/lib/librte_graph/graph_stats.c
> index 125e08d..f698bb3 100644
> --- a/lib/librte_graph/graph_stats.c
> +++ b/lib/librte_graph/graph_stats.c
> @@ -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;
>  }

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.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [dpdk-dev] [PATCH v2 0/2] bugfix for graph
  2021-04-22 11:52 [dpdk-dev] [PATCH 0/2] bugfix for graph Min Hu (Connor)
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 1/2] graph: fix memory leak Min Hu (Connor)
  2021-04-22 11:52 ` [dpdk-dev] [PATCH 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
@ 2021-05-06  7:16 ` Min Hu (Connor)
  2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 1/2] graph: fix memory leak Min Hu (Connor)
                     ` (2 more replies)
  2 siblings, 3 replies; 15+ messages in thread
From: Min Hu (Connor) @ 2021-05-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas, david.marchand, jerinj, kirankumark

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.

-- 
2.7.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [dpdk-dev] [PATCH v2 1/2] graph: fix memory leak
  2021-05-06  7:16 ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph Min Hu (Connor)
@ 2021-05-06  7:16   ` Min Hu (Connor)
  2021-05-10 13:26     ` David Marchand
  2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
  2021-06-03 16:40   ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph David Marchand
  2 siblings, 1 reply; 15+ messages in thread
From: Min Hu (Connor) @ 2021-05-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas, david.marchand, jerinj, kirankumark

From: HongBo Zheng <zhenghongbo3@huawei.com>

Fix function 'stats_mem_populate' return without
free dynamic memory referenced by 'stats'.

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 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c
index 125e08d..30e295d 100644
--- a/lib/graph/graph_stats.c
+++ b/lib/graph/graph_stats.c
@@ -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;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer
  2021-05-06  7:16 ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph Min Hu (Connor)
  2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 1/2] graph: fix memory leak Min Hu (Connor)
@ 2021-05-06  7:16   ` Min Hu (Connor)
  2021-05-06  9:01     ` Jerin Jacob
  2021-05-10 13:27     ` David Marchand
  2021-06-03 16:40   ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph David Marchand
  2 siblings, 2 replies; 15+ messages in thread
From: Min Hu (Connor) @ 2021-05-06  7:16 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas, david.marchand, jerinj, kirankumark

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(-)

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] graph: fix memory leak
  2021-05-04 14:15   ` [dpdk-dev] " David Marchand
@ 2021-05-06  7:18     ` Min Hu (Connor)
  0 siblings, 0 replies; 15+ messages in thread
From: Min Hu (Connor) @ 2021-05-06  7:18 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, Yigit, Ferruh, Jerin Jacob Kollanukkaran, Kiran Kumar Kokkilagadda



在 2021/5/4 22:15, David Marchand 写道:
> On Thu, Apr 22, 2021 at 1:52 PM Min Hu (Connor) <humin29@huawei.com> wrote:
>>
>> From: HongBo Zheng <zhenghongbo3@huawei.com>
>>
>> Fix function 'stats_mem_populate' return without
>> free dynamic memory referenced by 'stats'.
>>
>> 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/librte_graph/graph_stats.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/librte_graph/graph_stats.c b/lib/librte_graph/graph_stats.c
>> index 125e08d..f698bb3 100644
>> --- a/lib/librte_graph/graph_stats.c
>> +++ b/lib/librte_graph/graph_stats.c
>> @@ -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;
>>   }
> 
> 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.
> 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.
> 
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer
  2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
@ 2021-05-06  9:01     ` Jerin Jacob
  2021-05-10 13:27     ` David Marchand
  1 sibling, 0 replies; 15+ messages in thread
From: Jerin Jacob @ 2021-05-06  9:01 UTC (permalink / raw)
  To: Min Hu (Connor)
  Cc: dpdk-dev, Ferruh Yigit, Thomas Monjalon, David Marchand,
	Jerin Jacob, Kiran Kumar K

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
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/2] graph: fix memory leak
  2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 1/2] graph: fix memory leak Min Hu (Connor)
@ 2021-05-10 13:26     ` David Marchand
  0 siblings, 0 replies; 15+ messages in thread
From: David Marchand @ 2021-05-10 13:26 UTC (permalink / raw)
  To: Min Hu (Connor)
  Cc: dev, Yigit, Ferruh, Thomas Monjalon, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda

On Thu, May 6, 2021 at 9:16 AM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> From: HongBo Zheng <zhenghongbo3@huawei.com>
>
> Fix function 'stats_mem_populate' return without
> free dynamic memory referenced by 'stats'.
>
> 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>

-- 
David Marchand


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer
  2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
  2021-05-06  9:01     ` Jerin Jacob
@ 2021-05-10 13:27     ` David Marchand
  1 sibling, 0 replies; 15+ messages in thread
From: David Marchand @ 2021-05-10 13:27 UTC (permalink / raw)
  To: Min Hu (Connor)
  Cc: dev, Yigit, Ferruh, Thomas Monjalon, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda

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>

-- 
David Marchand


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/2] bugfix for graph
  2021-05-06  7:16 ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph Min Hu (Connor)
  2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 1/2] graph: fix memory leak Min Hu (Connor)
  2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
@ 2021-06-03 16:40   ` David Marchand
  2 siblings, 0 replies; 15+ messages in thread
From: David Marchand @ 2021-06-03 16:40 UTC (permalink / raw)
  To: Min Hu (Connor)
  Cc: dev, Yigit, Ferruh, Thomas Monjalon, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda

On Thu, May 6, 2021 at 9:16 AM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> 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(-)

Series applied, thanks.

-- 
David Marchand


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-06-03 16:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 11:52 [dpdk-dev] [PATCH 0/2] bugfix for graph Min Hu (Connor)
2021-04-22 11:52 ` [dpdk-dev] [PATCH 1/2] graph: fix memory leak Min Hu (Connor)
2021-04-23  3:52   ` [dpdk-dev] [EXT] " Kiran Kumar Kokkilagadda
2021-05-04 14:15   ` [dpdk-dev] " David Marchand
2021-05-06  7:18     ` Min Hu (Connor)
2021-04-22 11:52 ` [dpdk-dev] [PATCH 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
2021-04-23  3:52   ` [dpdk-dev] [EXT] " Kiran Kumar Kokkilagadda
2021-04-23  9:05   ` [dpdk-dev] " Jerin Jacob
2021-05-06  7:16 ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph Min Hu (Connor)
2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 1/2] graph: fix memory leak Min Hu (Connor)
2021-05-10 13:26     ` David Marchand
2021-05-06  7:16   ` [dpdk-dev] [PATCH v2 2/2] graph: fix dereferencing null pointer Min Hu (Connor)
2021-05-06  9:01     ` Jerin Jacob
2021-05-10 13:27     ` David Marchand
2021-06-03 16:40   ` [dpdk-dev] [PATCH v2 0/2] bugfix for graph David Marchand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.