lkml.org 
[lkml]   [2017]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] of: overlay: fix memory leak related to duplicated property
On Thu, Oct 12, 2017 at 10:07 PM, Lixin Wang
<alan.1.wang@nokia-sbell.com> wrote:
> From: alawang <alan.1.wang@nokia-sbell.com>
>
> Hello,
>
> Sorry It was my fault in last email that wrote the wrong subject and sign off name.
> Correct them this time.
> Thanks

This has to go below the '---' or it ends up in the commit message.
Please resend.

>
> 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@nokia-sbell.com>
> ---
> 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,
> --
> 2.6.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html

\
 
 \ /
  Last update: 2017-10-13 22:50    [W:0.301 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site