graph: fix memory leak in node clone
Checks
Commit Message
From: Pavan Nikhilesh <pbhagavatula@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 <pbhagavatula@marvell.com>
---
lib/graph/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
There is one more place in the node_clone function that needs to be modified:
if (clone_name(reg->name, node->name, name))
//goto free;
goto free_xstat;
@@ -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++)