mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Oleg.Karfich@wago.com
Cc: barebox@lists.infradead.org, Florian.Baeuerle@allegion.com
Subject: Re: [PATCH v2] commands: of_property: copy value instead of resizing
Date: Wed, 29 Aug 2018 09:20:06 +0200	[thread overview]
Message-ID: <20180829072006.vtdkfq6fzlihxlo7@pengutronix.de> (raw)
In-Reply-To: <1535472578-22131-1-git-send-email-oleg.karfich@wago.com>

On Tue, Aug 28, 2018 at 04:09:46PM +0000, Oleg.Karfich@wago.com wrote:
> Commit 748d1b8 adds the fixup feature to the above command. With this commit an
> unwanted free(data) on the freshly set property value is done if someone tries
> to set the value of an already present property (not the case for a new
> property). Furthermore in fixup mode the pointer fixup->data is freed when the
> fixup function is called more than once. This leads to a hanging system after
> calling of_dump -F many times.
> Fix this issues by copying the data to a new allocated memory area like a new
> property is created.
> 
> Signed-off-by: Oleg Karfich <oleg.karfich@wago.com>
> ---
> 
> Changes in v2:
> 
>         - slightly different solution like in [1]
>         - consider memory leak when a new property is created. Noted in [2]
>         - also consider hanging system when oftree -F is used
> 
> [1] http://lists.infradead.org/pipermail/barebox/2018-August/034444.html
> [2] http://lists.infradead.org/pipermail/barebox/2018-August/034446.html
> 
> ---
>  commands/of_property.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/commands/of_property.c b/commands/of_property.c
> index d0b923f..31e9b71 100644
> --- a/commands/of_property.c
> +++ b/commands/of_property.c
> @@ -270,9 +270,8 @@ static int do_of_property_set_now(struct device_node *root, const char *path,
>  		free(pp->value);
>  		pp->value_const = NULL;
>  
> -		/* limit property data to the actual size */
>  		if (len)
> -			pp->value = xrealloc(data, len);
> +			pp->value = xmemdup(data, len);
>  		else
>  			pp->value = NULL;
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2018-08-29  7:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 16:09 Oleg.Karfich
2018-08-29  7:20 ` Sascha Hauer [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=20180829072006.vtdkfq6fzlihxlo7@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=Florian.Baeuerle@allegion.com \
    --cc=Oleg.Karfich@wago.com \
    --cc=barebox@lists.infradead.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