From: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Lixin Wang <alan.1.wang-FTnzSCDXTkYjo0HpFSRKWA@public.gmane.org>,
Pantelis Antoniou
<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] of: overlay: fix memory leak related to duplicated property
Date: Fri, 13 Oct 2017 15:04:38 -0700 [thread overview]
Message-ID: <59E13876.5020801@gmail.com> (raw)
In-Reply-To: <1507864056-52089-1-git-send-email-alan.1.wang-FTnzSCDXTkYjo0HpFSRKWA@public.gmane.org>
Hi Rob,
On 10/12/17 20:07, Lixin Wang wrote:
> From: alawang <alan.1.wang-FTnzSCDXTkYjo0HpFSRKWA@public.gmane.org>
>
> Hello,
>
> Sorry It was my fault in last email that wrote the wrong subject and sign off name.
> Correct them this time.
> Thanks
>
> Function of_changeset_add_property or of_changeset_update_property may
> fails. In this case the property just allocated is never deallocated.
>
> Signed-off-by: Lixin Wang <alan.1.wang-FTnzSCDXTkYjo0HpFSRKWA@public.gmane.org>
> ---
> drivers/of/overlay.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> index 8ecfee3..af3b9a1 100644
> --- a/drivers/of/overlay.c
> +++ b/drivers/of/overlay.c
> @@ -162,6 +162,7 @@ static int of_overlay_apply_single_property(struct of_overlay *ov,
> bool is_symbols_node)
> {
> struct property *propn = NULL, *tprop;
> + int ret = 0;
>
> /* NOTE: Multiple changes of single properties not supported */
> tprop = of_find_property(target, prop->name, NULL);
> @@ -186,10 +187,16 @@ static int of_overlay_apply_single_property(struct of_overlay *ov,
>
> /* not found? add */
> if (tprop == NULL)
> - return of_changeset_add_property(&ov->cset, target, propn);
> -
> - /* found? update */
> - return of_changeset_update_property(&ov->cset, target, propn);
> + ret = of_changeset_add_property(&ov->cset, target, propn);
> + else /* found? update */
> + ret = of_changeset_update_property(&ov->cset, target, propn);
> +
> + if (ret) {
> + kfree(propn->name);
> + kfree(propn->value);
> + kfree(propn);
> + }
> + return ret;
> }
>
> static int of_overlay_apply_single_device_node(struct of_overlay *ov,
>
Just a heads up.
This will conflict with my patch series "[PATCH 00/12] of: overlay: clean up
device tree overlay code" [1]. The issue that Lixin has identified will
still remain after applying my patch series, and can be fixed in the same
manner as his patch, just different context, including variable names.
[1] https://lkml.org/lkml/2017/10/2/679
-Frank
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-10-13 22:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 1:53 [PATCH 1/2] of: overlay: fix memory leak related to duplicated property alawang
2017-10-13 3:07 ` [PATCH] " Lixin Wang
[not found] ` <1507864056-52089-1-git-send-email-alan.1.wang-FTnzSCDXTkYjo0HpFSRKWA@public.gmane.org>
2017-10-13 20:49 ` Rob Herring
2017-10-13 22:04 ` Frank Rowand [this message]
2017-10-16 2:35 ` Wang, Alan 1. (NSB - CN/Hangzhou)
[not found] ` <VI1PR07MB342187128B48F66C464401A2A24F0-ErKcd1u/gBOORytiVngBPTzdlHkvsOLVvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-10-16 6:07 ` Frank Rowand
2017-10-16 20:54 ` Rob Herring
2017-10-16 9:54 ` Lixin Wang
[not found] ` <1508147672-58291-1-git-send-email-alan.1.wang-FTnzSCDXTkYjo0HpFSRKWA@public.gmane.org>
2017-10-17 14:06 ` Rob Herring
2017-10-13 21:39 ` [PATCH 1/2] " Frank Rowand
[not found] ` <59E1328D.2040007-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-10-16 2:29 ` Wang, Alan 1. (NSB - CN/Hangzhou)
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=59E13876.5020801@gmail.com \
--to=frowand.list-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=alan.1.wang-FTnzSCDXTkYjo0HpFSRKWA@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@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).