From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bknsF-0001xL-Ux for barebox@lists.infradead.org; Fri, 16 Sep 2016 07:47:53 +0000 Date: Fri, 16 Sep 2016 09:47:30 +0200 From: Sascha Hauer Message-ID: <20160916074730.46zufu6nqcilziey@pengutronix.de> References: <1474008220-7601-1-git-send-email-m.olbrich@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1474008220-7601-1-git-send-email-m.olbrich@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [PATCH v2 1/3] state: copy backend of_path string To: Michael Olbrich Cc: barebox@lists.infradead.org On Fri, Sep 16, 2016 at 08:43:38AM +0200, Michael Olbrich wrote: > Caching pointers to device tree nodes or names is not save. The barebox > internal device tree may be changed by loading a new device tree or through > fixup handlers. As a result, the string may be deleted. > Use local copies of the full path instead. > > Signed-off-by: Michael Olbrich > --- > Changes since v1: > - First patch split into two patches Applied, thanks Sascha > > common/state/backend.c | 3 ++- > common/state/state.h | 2 +- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/common/state/backend.c b/common/state/backend.c > index 2f2e6dfd32d1..5235bb0283dd 100644 > --- a/common/state/backend.c > +++ b/common/state/backend.c > @@ -164,7 +164,7 @@ int state_backend_init(struct state_backend *backend, struct device_d *dev, > if (ret) > goto out_free_format; > > - backend->of_path = of_path; > + backend->of_path = xstrdup(of_path); > > return 0; > > @@ -185,4 +185,5 @@ void state_backend_free(struct state_backend *backend) > state_storage_free(&backend->storage); > if (backend->format) > state_format_free(backend->format); > + free(backend->of_path); > } > diff --git a/common/state/state.h b/common/state/state.h > index 32146ca1bbc7..f930d06195b2 100644 > --- a/common/state/state.h > +++ b/common/state/state.h > @@ -87,7 +87,7 @@ struct state_backend_storage { > struct state_backend { > struct state_backend_format *format; > struct state_backend_storage storage; > - const char *of_path; > + char *of_path; > }; > > struct state { > -- > 2.8.1 > > > _______________________________________________ > 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