devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] livetree.c: Fix memory leak
@ 2017-02-07 21:26 Jean-Christophe Dubois
       [not found] ` <20170207212625.20538-1-jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Jean-Christophe Dubois @ 2017-02-07 21:26 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: Jean-Christophe Dubois

When running coverity on dtc source code the following error is reported.

==========================================================================
*** CID 1370967:  Resource leaks  (RESOURCE_LEAK)
/tools/dtc/livetree.c: 850 in add_fixup_entry()
844		if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
845			die("arguments should not contain ':'\n");
846
847		xasprintf(&entry, "%s:%s:%u",
848			  node->fullpath, prop->name, m->offset);
849		append_to_property(fn, m->ref, entry, strlen(entry) + 1);
>>>     CID 1370967:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "entry" going out of scope leaks the storage it points to.
850     }
==========================================================================

Fix the leak.

Signed-off-by: Jean-Christophe Dubois <jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
---
 livetree.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/livetree.c b/livetree.c
index afa2f67..994b6c2 100644
--- a/livetree.c
+++ b/livetree.c
@@ -847,6 +847,8 @@ static void add_fixup_entry(struct dt_info *dti, struct node *fn,
 	xasprintf(&entry, "%s:%s:%u",
 			node->fullpath, prop->name, m->offset);
 	append_to_property(fn, m->ref, entry, strlen(entry) + 1);
+
+	free(entry);
 }
 
 static void generate_fixups_tree_internal(struct dt_info *dti,
-- 
2.9.3

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

end of thread, other threads:[~2017-02-08  6:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-07 21:26 [PATCH] livetree.c: Fix memory leak Jean-Christophe Dubois
     [not found] ` <20170207212625.20538-1-jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
2017-02-08  6:40   ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).