From cb9241ae345378b7193b3d7c9621e8abe657faa6 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Dubois Date: Mon, 11 Jul 2016 00:16:52 +0200 Subject: [PATCH] DTC: Fix memory leak on flatname. If flatname was not referenced by the "node" structure, the reference to the allocated string is lost at function exit. We need to free it if is not used by "node". Signed-off-by: Jean-Christophe Dubois Signed-off-by: David Gibson --- flattree.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flattree.c b/flattree.c index ec14954..089b976 100644 --- a/flattree.c +++ b/flattree.c @@ -797,6 +797,10 @@ static struct node *unflatten_tree(struct inbuf *dtbuf, } } while (val != FDT_END_NODE); + if (node->name != flatname) { + free(flatname); + } + return node; }