> -----Original Message-----
> From: pbhagavat...@marvell.com <pbhagavat...@marvell.com>
> Sent: Friday, November 1, 2024 1:08 PM
> To: Jerin Jacob <jer...@marvell.com>; chcch...@163.com; Kiran Kumar
> Kokkilagadda <kirankum...@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpu...@marvell.com>; Zhirun Yan <yanzhirun_...@163.com>
> Cc: dev@dpdk.org; Pavan Nikhilesh Bhagavatula
> <pbhagavat...@marvell.com>
> Subject: [PATCH v2] graph: fix memory leak in node clone
>
> From: Pavan Nikhilesh <pbhagavat...@marvell.com>
>
> Free memory allocated for the node when xstats memory allocation fails.
>
> Coverity issue: 445529
> Fixes: 070db97e017b ("graph: support node xstats")
>
> Signed-off-by: Pavan Nikhilesh <pbhagavat...@marvell.com>
> ---
Acked-by: Kiran Kumar Kokkilagadda <kirankum...@marvell.com>
> v2 Changes:
> - Fix one more leak. (Huichao cai)
>
> lib/graph/node.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/graph/node.c b/lib/graph/node.c index
> f15922892e..63db629da8 100644
> --- a/lib/graph/node.c
> +++ b/lib/graph/node.c
> @@ -156,7 +156,7 @@ node_clone(struct node *node, const char *name)
> (node->xstats->nb_xstats *
> RTE_NODE_XSTAT_DESC_SIZE));
> if (reg->xstats == NULL) {
> rte_errno = ENOMEM;
> - goto fail;
> + goto free;
> }
>
> for (i = 0; i < node->xstats->nb_xstats; i++) @@ -178,7 +178,7
> @@ node_clone(struct node *node, const char *name)
>
> /* Naming ceremony of the new node. name is node->name + "-" +
> name */
> if (clone_name(reg->name, node->name, name))
> - goto free;
> + goto free_xstat;
>
> rc = __rte_node_register(reg);
> free_xstat:
> --
> 2.25.1