From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Jean-Christophe Dubois <jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] livetree.c: Fix memory leak
Date: Wed, 8 Feb 2017 17:40:57 +1100 [thread overview]
Message-ID: <20170208064057.GJ17644@umbus.fritz.box> (raw)
In-Reply-To: <20170207212625.20538-1-jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1692 bytes --]
On Tue, Feb 07, 2017 at 10:26:25PM +0100, Jean-Christophe Dubois wrote:
> 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>
Applied, thanks.
> ---
> 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,
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
prev parent reply other threads:[~2017-02-08 6:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170208064057.GJ17644@umbus.fritz.box \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).