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,
jdl-CYoMK+44s/E@public.gmane.org
Subject: Re: [PATCH] DTC: Fix memory leak on flatname.
Date: Mon, 11 Jul 2016 11:29:10 +1000 [thread overview]
Message-ID: <20160711012910.GB16355@voom.fritz.box> (raw)
In-Reply-To: <1468189012-1584-1-git-send-email-jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1106 bytes --]
On Mon, Jul 11, 2016 at 12:16:52AM +0200, Jean-Christophe Dubois wrote:
> 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 <jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
TBH, I'm not generally particularly fussed by memory leaks in dtc,
since it only has a short runtime. Still, I've applied this fix
because, why not.
> ---
> 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;
> }
>
--
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:[~2016-07-11 1:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-10 22:16 [PATCH] DTC: Fix memory leak on flatname Jean-Christophe Dubois
[not found] ` <1468189012-1584-1-git-send-email-jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
2016-07-11 1:29 ` 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=20160711012910.GB16355@voom.fritz.box \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org \
--cc=jdl-CYoMK+44s/E@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).